Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Oct 19, 2019 9:20 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How do I know if the port for TCPsocket test is open?
PostPosted: Tue Nov 13, 2012 4:36 pm 
Offline

Joined: Fri Oct 12, 2012 1:18 pm
Posts: 7
I have set up a TCPsocket test using the example program from the online documentaton: Compiles ok. External test program attempts to send a packet to this program. He gets a timeout. I'M CONTINUALLY LOOPING AND NEVER SEE THE PING.

QUESTION: HOW DO I KNOW THAT THE PORT I'VE CHOSEN IS OPEN? AND IF NOT, HOW DO I OPEN IT.

I'M USING MAC OS 7.4 LION.

// InitTCPsocket
// Author: Ken Reed
// Date 11/13/12
// Action: Sets up the TCPSocket as server for communication with the analytic components

Dim start, stop As Integer
Dim NNsocket As TCPSocket

NNsocket = New TCPSocket

//set port and address
Address = " my ip here "
NNsocket.Port = 7000

MsgBox( "Beginning synchronous connection ... " )

start = Ticks/60/60 //minutes
while not NNsocket.IsConnected
// check to see if the socket got an error
if NNsocket.LastErrorCode <> 0 then
MsgBox( "Socket Error: " + str( NNsocket.LastErrorCode ))
Exit
end if
NNsocket.Poll
Wend
stop = Ticks/60/60

//if we broke the loop because we're connected
if NNsocket.IsConnected then
MsgBox( "Socket Connected in " + Str( stop - start ) + " minutes" )
Return true
else
//Socket broke loop because of an error
MsgBox( "Socket failed to connect after " + Str( stop - start ) + " minutes" )
Return false
end if


Top
 Profile  
Reply with quote  
 Post subject: Re: How do I know if the port for TCPsocket test is open?
PostPosted: Tue Nov 13, 2012 4:47 pm 
Offline
User avatar

Joined: Sat Nov 11, 2006 2:43 pm
Posts: 1221
Location: This poster has left the forums
http://docs.realsoftware.com/index.php/TCPSocket.Listen

_________________
%Invalidforumsignatureexception% user signature not found


Top
 Profile  
Reply with quote  
 Post subject: Re: How do I know if the port for TCPsocket test is open?
PostPosted: Tue Nov 13, 2012 4:49 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
If you set the socket's port to 0, RS will automatically select an unused port (1024-65535) when connect or listen is called. After connection, you can read the port number that was chosen. You must call either Listen (if you're waiting for the remote host to connect) or Connect (if the remote host is listening for you to connect) otherwise the socket will never be connected.

If a port is already in use (by you or any other program) the Socket's LastErrorCode property will be 105.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: How do I know if the port for TCPsocket test is open?
PostPosted: Tue Nov 13, 2012 6:10 pm 
Offline

Joined: Fri Oct 12, 2012 1:18 pm
Posts: 7
Thanks, big help. Will give it a try.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group