looped client sending && TODOs
This commit is contained in:
parent
faa63577ee
commit
368c57c285
@ -23,19 +23,29 @@ void send_socket(char *text, int socket);
|
||||
int main(void)
|
||||
{
|
||||
int listen_socket = socket(AF_INET, SOCK_STREAM, 0); //CREATE SERVER SOCKET
|
||||
char *line = NULL;
|
||||
size_t line_length = 0;
|
||||
|
||||
//DEFINE SERVER ADDRESS
|
||||
struct sockaddr_in server_addr;
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(SERVER_PORT);
|
||||
server_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
int connectStatus = connect(listen_socket, (SA *) &server_addr, sizeof(server_addr)); //CONNECT
|
||||
|
||||
if (connectStatus < 0) why2_die("Connecting failed.");
|
||||
|
||||
send_socket("123456789123456789", listen_socket);
|
||||
for (;;)
|
||||
{
|
||||
printf(">>> ");
|
||||
getline(&line, &line_length, stdin);
|
||||
|
||||
printf("%s\n", line);
|
||||
|
||||
send_socket(line, listen_socket);
|
||||
}
|
||||
|
||||
free(line); //TODO: Unreachable; add exit
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -43,11 +43,11 @@ int main(void)
|
||||
//LOOP ACCEPT
|
||||
for (;;)
|
||||
{
|
||||
accepted = accept(listen_socket, (SA *) NULL, NULL); //ACCEPT NEW SOCKET //TODO: CLOSE
|
||||
accepted = accept(listen_socket, (SA *) NULL, NULL); //ACCEPT NEW SOCKET //TODO: CLOSE (not only this one)
|
||||
|
||||
if (accepted == -1) why2_die("Accepting socket failed!");
|
||||
|
||||
received = read_socket(accepted);
|
||||
received = read_socket(accepted); //TODO: Add multithreading
|
||||
|
||||
if (received == NULL) continue; //FAILED
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user