View Single Post
Old Mar 2nd, 2008, 10:34 AM   #3
Soulstorm
Hobbyist Programmer
 
Soulstorm's Avatar
 
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 243
Rep Power: 3 Soulstorm is on a distinguished road
Re: Simple BSD Sockets Problem

Quote:
Originally Posted by Game_Ender View Post
Where is your server code?

Well you aren't check the return of "gethostbyname" which could very well be NULL. That would be a quick crash. You also don't zero out you sockaddr_in structure before using it. Here is some code I have that does a similar thing:
cpp Syntax (Toggle Plain Text)
  1. memset(&m_addr, 0, sizeof(m_addr));
  2. m_addr.sin_family = AF_INET; // host byte order
  3. m_addr.sin_port = htons(port); // short, network byte order
  4. m_addr.sin_addr = *((struct in_addr *)he->h_addr);

I think you are trying to do something simular with this:
cpp Syntax (Toggle Plain Text)
  1. memset(their_addr.sin_zero, '\0', sizeof their_addr.sin_zero);

Wikipedia has good article here.

Thanks for the reply. There is no server code. The host I connect to is an IRC network host.
__________________
Project::Soulstorm (personal homepage)
Soulstorm is offline   Reply With Quote