--- In salva g <> wrote:
> struct sockaddr_in ACS;
>
> client = socket(AF_INET,SOCK_STREAM,0);
>
> ACS.sin_family = AF_INET;
> ACS.sin_addr.s_addr = inet_addr("192.168.0.60");
> ACS.sin_port = htons(6001);
> if (connect(client,(struct sockaddr*)&ACS,sizeof(ACS))<0)
> {
> "Error when connecting" retrying, etc....
> }
> else
> continue...
>
I don't see anything immediately wrong with your code. The cast to (struct
sockaddr*) is necessary because ACS is a sockaddr_in and the connect function
takes a generic struct sockaddr*. Most of the socket functions behave this way.
You say this problem occurs when running your client and the server is down? I
think connect is designed to try for 2-3 minutes before actually failing to
establish a connection. If this isn't acceptable then you need to make your
socket non blocking and use select() or some other mechanism to determine when
a connection is established.
Mike
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|