Hey i was just writing a simple server i'm using accept() in a loop to emit constant greeting but i dont know why my code stucks at single send() i mean it asks for input only once --> it asks for input --> i give input--> it emits succsfully to port 3490 or whatever in my code ---> but it does not asks for another input even though my code is in a loop Help me there check out my code -->
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netinet/in.h>
# define BACKLOG 5
int main(int argc,char *argv[]){
int status,socket_result,new_fd;
struct addrinfo hints,*result;
struct sockaddr_storage their_addr;
socklen_t addr_size;
memset(&hints,0,sizeof hints);
hints.ai_family = AF_INET;
hints.ai_flags = AI_PASSIVE;
hints.ai_socktype = SOCK_STREAM;
status = getaddrinfo(NULL,"3490",&hints,&result);
socket_result = socket(result->ai_family,result->ai_socktype,result->ai_protocol);
if(socket_result == -1){
printf("server might be alrey running");
return 1;
}
bind(socket_result,result->ai_addr,result->ai_addrlen);
while(1){
char data[13];
listen(socket_result,BACKLOG);
addr_size = sizeof their_addr;
new_fd = accept(socket_result,(struct sockaddr *)&their_addr,&addr_size);
printf("enter input \n");
scanf("%s",data);
printf("about to send your input");
send(new_fd,data,13,0);
printf("input sent");}
return 0;
}