bind, listen, accept on XP

Miscellaneous Forums/General Discussion/bind, listen, accept on XP

Does anyone know of an include file which will allow these system calls to play whilst trying to compile C on a XP machine ? I have a sneeking suspicion that they are Unix / Linux only system calls - so am considering a dual boot affair . I have tried compiling in both Dev-C (bloodshed) and VB studio 05 with the same compile errors, i.e. bind, accept, listen etc. not found on my XP system.

regards,

Try...

#include <windows.h>
#include <winsock.h>


You'll also need to link with libwsock32.a for mingw, something else for msvc.

Thanks Mark.....

Regards -

I've only got two compile errors left now related to 'read' and write' calls, I'm off to see if I can hunt down what includes I need but if you can help it'd be very much appreciated.


 /*  suspect bzero need to be a memset */   
     //bzero((char *) &serv_addr, sizeof(serv_addr));    /* 44 */
     
        memset((char *) &serv_addr, 0, sizeof(serv_addr));
     /* end of query 2 */
     
     portno = atoi(argv[1]);
     serv_addr.sin_family = AF_INET;
     serv_addr.sin_addr.s_addr = INADDR_ANY;
     serv_addr.sin_port = htons(portno);
     if (bind(sockfd, (struct sockaddr *) &serv_addr,
              sizeof(serv_addr)) < 0) 
              error("ERROR on binding");
     listen(sockfd,5);
     clilen = sizeof(cli_addr);
     newsockfd = accept(sockfd, 
                 (struct sockaddr *) &cli_addr, 
                 &clilen);
     if (newsockfd < 0) 
          error("ERROR on accept");
     //bzero(buffer,256);
	 //memset(buffer,256);
     n = read(newsockfd,buffer,255);
     if (n < 0) error("ERROR reading from socket");
     printf("Here is the message: %s\n",buffer);
     n = write(newsockfd,"I got your message",18);
     if (n < 0) error("ERROR writing to socket");
     return 0; 
}





regards,