added IP select at client startup

This commit is contained in:
Václav Šmejkal 2023-02-20 19:34:58 +01:00
parent 2fb4c739b2
commit 54a039a60b
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -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.");