and i get this error
error: syntax error before numeric constant
and this errors occurs near this line:
int listen(sock,5);
need help
and this is begining of my iterative server
can any one check my code to see if im on the right track:
Expand|Select|Wrap|Line Numbers
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <netdb.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h> // for strlen()
- #define EOB "$$"
- #define KB_size 1024
- int ClientNo = 0;
- int main(void)
- {
- int sock;
- int intPort;
- int NoClients;
- int num;
- int i;
- char host[80];
- int mssock; /* fd from accept return */
- struct sockaddr_in server; /* socket struct for server connection */
- struct sockaddr_in client; /* socket struct for client connection */
- int clientLen; /* returned length of client from accept() */
- int rval; /* return value from read() */
- char KB_buff[KB_size];
- sock = sockTCP_create();
- /* Open a socket, not bound yet. */
- if ((sock = socket(AF_INET, SOCK_STREAM, 0)) > 0)
- printf("Opening stream socket \n");
- // Binding a socket //
- printf("Could you Please Enter port: \n");
- fgets(KB_buff, KB_size, stdin);
- intPort = atoi(KB_buff);
- bzero((char *) &server, sizeof(server));
- server.sin_family = AF_INET;
- server.sin_addr.s_addr = INADDR_ANY;
- server.sin_port = htons(intPort);
- (bind(sock, (struct sockaddr *) &server, sizeof(server)));
- printf("Socket has port %hu\n", ntohs(server.sin_port));
- //Listen a socket///
- int listen(sock,5);
- if (listen < 0)
- printf("Socket is listening");
- //Usess accept function to accept an incoming connection request//
- }