Hi,
I want to build a client/server chat program for the dos environment. I have no idea about socket programming. Is there any tutorial which can help me in this? Any website which explains this?
Hi,
I want to build a client/server chat program for the dos environment. I have no idea about socket programming. Is there any tutorial which can help me in this? Any website which explains this?
Last edited by Silverdream; 03-29-2002 at 03:44 AM.
Check out these include files.
#include <sys/socket.h>
#include <netinet/in.h>
You may want to really look at this structure.
struct sockaddr_in servaddr;
Code:/* create socket, quit if error */ if ( (sockfd = socket(AF_INET,SOCK_STREAM,0)) < 0) { printf("socket error.\n"); exit(0); } /* servaddr values */ bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(atoi(argv[2])); servaddr.sin_addr.s_addr = inet_addr(argv[1]); /* connect to server, quit if error */ if(connect(sockfd, (SA *) &servaddr, sizeof(servaddr)) < 0) { printf("did not connect!\n"); exit(0); } else printf("connected!\n"); /* Send message to server */ write(sockfd, serverMessage, strlen(serverMessage));
http://www.KBeutler.com
hi,
Thanx for ur response. Could you please be more elaborate in your answer. I just wanted to start of with socket programming in C for dos. I cant understand ur code because its complicated for me to comprehend.
Well that's why learn about socket programming, BEFORE you ask questions about it. You might want to try Java for this program. It's very similar to C in structure, etc (like the {}'s), but it's all very simplified as far as the variety of functions go. It's C derived so you should pick it up quick, and was designed around this kind of problem. XML will help you a lot too.
Thats why i had inlcuded in my question that i need a web site which has some tutorials/books on socket programming.