Accepting Sockets with accept()
Code:
if ((new_socket = accept(master_socket, (struct sockaddr *)&address, sizeof(address);/*&addrlen*/))<0)
If i didnt use new_socket what would i use to send and recv from?
I mean how does accept work? Do i have to make new_socket equal accept?
or can i just send information to mastersocket and exclude the over bearing
integer new_socket.
oh one more thing because i havent compiled my program yet I was wondering if
sizeof(address) would take the place of addrlen=sizeof(address) as I posted above.
You did understand the question right?
I just wanted to mkae sure you understand the question and gave me the correct answer. if i use accept without using new_socket as the intiger then i cant send to mastersocket instead of sending to new_socket.
By the way thanks for you help.
and hows this lookf so far?
Code:
int mastersocket;
fd_set descrip;
int activity, user;
int client_socket[700];
int maxclients = 700;
if (mastersocket=socket(AF_INET,SOCK_STREAM
{
fatal("Creating mastersocket, AF_INET SOCK
exit(EXIT_FAILURE); }
struct sockaddr_in address;
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons(port);
/*Binding a socket callled mastersocket */
if(bind(mastersocket,(struct sockaddr *)&ad
{
fatal("Binding mastersocket, AF_INET SOCK_
exit(EXIT_FAILURE); }
/* Listening to mastersocket */
if(listen(mastersocket, 3) == -1)
{
fatal("Listening to mastersocket, AF_INET
exit(EXIT_FAILURE); }
fcntl(mastersocket, F_SETFL, FNDELAY);