added IP select at client startup
This commit is contained in:
parent
2fb4c739b2
commit
54a039a60b
@ -18,6 +18,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#include <why2/chat/common.h>
|
#include <why2/chat/common.h>
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
void send_socket(char *text, int socket);
|
void send_socket(char *text, int socket);
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
@ -32,6 +34,11 @@ int main(void)
|
|||||||
server_addr.sin_port = htons(SERVER_PORT);
|
server_addr.sin_port = htons(SERVER_PORT);
|
||||||
server_addr.sin_addr.s_addr = INADDR_ANY;
|
server_addr.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
|
||||||
|
printf("Welcome.\n\nEnter IP Address:\n>>> ");
|
||||||
|
getline(&line, &line_length, stdin);
|
||||||
|
|
||||||
|
server_addr.sin_addr.s_addr = inet_addr(line);
|
||||||
|
|
||||||
int connectStatus = connect(listen_socket, (SA *) &server_addr, sizeof(server_addr)); //CONNECT
|
int connectStatus = connect(listen_socket, (SA *) &server_addr, sizeof(server_addr)); //CONNECT
|
||||||
|
|
||||||
if (connectStatus < 0) why2_die("Connecting failed.");
|
if (connectStatus < 0) why2_die("Connecting failed.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user