New topic: TCP Socket - nonexisting IP problem
<http://forums.realsoftware.com/viewtopic.php?t=46822> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message mapmusic Post subject: TCP Socket - nonexisting IP problemPosted: Tue Feb 05, 2013 6:15 am Joined: Tue Oct 30, 2012 4:23 am Posts: 8 Hello Network experts, I need check possibility of connect before running some code on TCP SOcket. I use TCP socket example from Reference Guide, which works well on IPs which are available. I got into problem, when I try to connect to nonexisting IP. Problem is when I am connecting there, in "While" part I have IsConnetcted= False and LastErrorCode=0, so code is cycling . Have you any tip to check this in code ? Thanks Martin My Code:Function TCP_Connect(xIP as string, xPort as integer) As Boolean Dim start, stop as Integer Dim conn as Boolean Dim TCPSocket1 as TCPSocket TCPSocket1 = New TCPSocket TCPSocket1.Address = xIP TCPSocket1.Port = xPort TCPSocket1.Connect start = Ticks While Not TCPSocket1.IsConnected If TCPSocket1.LastErrorCode <> 0 then StatusBar.text = "Socket Error: " + str(TCPSocket1.LastErrorCode) Exit End If TCPSocket1.Poll Wend stop = Ticks If TCPSocket1.IsConnected then StatusBar.text= "Socket Connected in " + Str(stop - start) + " ticks" conn = true Else StatusBar.text= "Socket failed to connect. It took " + Str(stop - start) + _ " ticks to figure that out" conn= false End If TCPSocket1.Close StatusBar.text= "Socket closed" return conn End Function _________________ --- @MacOS 10.7.5/MBPro Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
