Ah.  I see.  Thank you.  Before I posted my question I read as much
information on all this as I could including my old postings from last year
and the wsocket.hlp file.   As I understand it then, the Wsocket.hlp file is
wrong or even worse, vague giving the impression that something is possible
when it really isn't.  

<QUOTE from wsocket.hlp>
Applies to
TWSocket

Declaration
Function Listen: Integer; 

Description
The listen method is used to build a server application where a given socket
must wait for incomming remote connections. The listen method ask the
underlaying level to wait for connection. It is non blocking: listen returns
immediately whitout waiting for an actual connection. When a connection will
be available at a later time when the client connected, the
OnSessionAvailable event will be generated. The OnSessionAvailable event
handler will normally call the accept method to retreive the client
connection handle.

Before calling the listen method, you must properly setup the Addr, Port and
Proto properties.
<END QUOTE>

The example that follows in the .hlp file uses telnet not tcp or udp.

Perhaps an extra statement in the wsocket.hlp file that this does _not_
apply to UDP and that listen does not ever generate a call to
OnSessionAvailable would have saved me some time.

Cheers,

John Dammeyer


Wireless CAN with the CANRF module now available.
http://www.autoartisans.com/products
Automation Artisans Inc.
Ph. 1 250 544 4950


> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Francois PIETTE
> Sent: Saturday, June 10, 2006 11:20 AM
> To: ICS support mailing
> Subject: Re: [twsocket] When does OnSessionAvailable event fire
> 
> 
> > I think I'm missing something critical but can't quite 
> figure it out.
> 
> Your are missing the fact that you use UDP and not TCP. UDP is 
> connectionless and sessionless. So don't use TWSocketServer. 
> Use TWSocket, 
> make it listen and the just handle OnDataAvailable event to 
> call Receive to 
> get the incomming datagrams.
> Have a look at the document "TCP/UDP primer" available from 
> support page at 
> my website.
> --
> [EMAIL PROTECTED]
> http://www.overbyte.be
> 
> 
> ----- Original Message ----- 
> From: "John Dammeyer" <[EMAIL PROTECTED]>
> To: "'ICS support mailing'" <twsocket@elists.org>
> Sent: Saturday, June 10, 2006 8:04 PM
> Subject: [twsocket] When does OnSessionAvailable event fire
> 
> 
> > Hi,
> >
> > I've finally been able to restart a project from last 
> October.  Something
> > has gone missing and code that used to work doesn't 
> anymore.  So I have to
> > sort of start over.  I've followed the example code, looked 
> at my postings
> > from back then in the archives but I'm having problems with 
> the following
> > sequence.
> >
> >
> > On FormShow I execute the following code:
> >
> >    if FirstTime then begin
> >        SrvSocket.Proto   := 'udp';
> >        SrvSocket.Addr    := '127.0.0.1';        // Use loopback
> >        SrvSocket.Port    := PortEdit.Text;    // Wait on 
> this port (4000).
> >        SrvSocket.Listen;                      // Start 
> listening for 
> > client
> > which also fires
> >      //
> > OnSessionConnected.
> >   FirstTime := FALSE;
> >        PortEdit.Enabled := FALSE;
> >    end;
> >
> > As per the example in the FAQ I want to run this method when
> > 'OnSessionAvailable' fires but it never happens.  What's 
> needed to make 
> > this
> > event fire?  Running a client on that port (4000) doesn't seem to do
> > anything while sending UDP messages to that port from a 
> client app does 
> > get
> > through.
> >
> > I think I'm missing something critical but can't quite 
> figure it out.
> >
> > Thanks
> >
> > John Dammeyer
> >
> > procedure TForm1.SrvSocketSessionAvailable(Sender: TObject; 
> ErrCode: 
> > Word);
> > var
> >    NewHSocket : TSocket;
> >    PeerName   : TSockAddrIn;
> >    Peer       : String;
> > begin
> >    PortEdit.Enabled := TRUE;
> >    { We need to accept the client connection }
> >    NewHSocket := SrvSocket.Accept;
> >
> >    { And then associate this connection with our client socket }
> >    CliSocket.Dup(NewHSocket);
> >
> >    { Wants to know who is connected to display on screen }
> >    CliSocket.GetPeerName(PeerName, Sizeof(PeerName));
> >
> >    { User likes to see internet address in dot notation }
> >    Peer := IntToStr(ord(PeerName.sin_addr.S_un_b.s_b1)) + '.' +
> >            IntToStr(ord(PeerName.sin_addr.S_un_b.s_b2)) + '.' +
> >            IntToStr(ord(PeerName.sin_addr.S_un_b.s_b3)) + '.' +
> >            IntToStr(ord(PeerName.sin_addr.S_un_b.s_b4));
> >    InfoLabel.Caption := 'Remote ' + Peer +
> >                         ' connected. Port:' + CliSocket.GetPeerPort;
> >
> >    { Send a welcome message to the client }
> >    //CliSocket.SendStr('Hello' + #13 + #10);
> >
> >    { Enable the server user to disconect the client }
> >    DisconnectButton.Enabled := TRUE;
> >    InitDisplayButton.Enabled := TRUE;
> > end;
> >
> > -- 
> > To unsubscribe or change your settings for TWSocket mailing list
> > please goto http://www.elists.org/mailman/listinfo/twsocket
> > Visit our website at http://www.overbyte.be 
> 
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
> 
> 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to