Problem in a socket program

This is a discussion on Problem in a socket program within the Linux Programming forums, part of the Platform Specific Boards category; Hi,
With the program below, i am trying to connect to a web host. But there is a problem; the ...

Problem in a socket program

Hi,

With the program below, i am trying to connect to a web host. But there is a problem; the line that prints "abcd" shows up when i enter a correct IP address, otherwise it doesn't. Shouldn't it run before the connect() statement, inependent of the result of the connect() ? Or is that something that i don't know about Linux programming? I am waiting for your help.