ts-7000
[Top] [All Lists]

[ts-7000] Re: ts7800 connect socket‏

To:
Subject: [ts-7000] Re: ts7800 connect socket‏
From: "machv0" <>
Date: Tue, 29 Sep 2009 17:02:00 -0000
--- 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/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU