May 31, 2012 at 9:00pm UTC
i new to socket programming. i built a chatting software. the program compiles fine but doesn't work as expected. Please help.
Last edited on Jun 3, 2012 at 4:09am UTC
May 31, 2012 at 9:03pm UTC
Since I don't want to go get a second computer to compile and run this on, would you mind telling us what it isn't doing correctly?
May 31, 2012 at 9:09pm UTC
Why do you have two sockets?
You can't use zero for the protocol in:
socket(AF_INET, SOCK_STREAM, 0);
You have to specify a value, probably IPPROTO_TCP on Windows.
You don't set the address size in:
accept(sockfd, (struct sockaddr *)&their_addr, &sin_size);
The rest isn't readable, you need to use the code format tags to format the code.
Last edited on May 31, 2012 at 11:10pm UTC
May 31, 2012 at 9:15pm UTC
when i run two instances of this program one for listening and the other for connecting, the listening one doesn't seem to be connected. more over both the connect() statements reurn the value 0.
Then when i type in something in conneting one instance and it keeps on waiting for the reply from the listening side.
May 31, 2012 at 9:20pm UTC
You haven't answered my question above. Why do you have two sockets?
Without formatting your code with code tags, it remains unreadable. You have other code errors too, but they're not obvious because of the formatting.
Jun 1, 2012 at 3:11am UTC
ok friends i got the errror....
thanks