Trying to make a console app that serves as a Server receiving TCP connections But when I add the Code
MainServerSocket.Listen to Event Run I get an Error (See image attached)
Anybody have a Hit on what I’m doing wrong xD
Make a property of the serversocket subclass to App or in a module then make an instance with New
Thanks for that fast reply.
BUT I’m still lost … I am extremely new to Xojo
Sooo i should create a property Named ServerSocket within the socket itself or just under App?
In App add a property name it MyServer As MainServerSocket.
In App.Open event: MyServer = New MainServerSocket
On the first line or so.
…and then use MyServer.Listen
Your problem is that you didn’t create an instance of your ServerSocket subclass.
Thanks guys that did the trick and this also helped me wrap my head around some Basics
Now to Pass the connection onto another socket and trade file … The Fun Begins
Whoa wait… if you are using ServerSocket, it already passes the connections around for you. You don’t need to do anything to get that to work.
On Greg’s note … can’t get Addsocket event under MainServerSocket to fire If a ServerSocket enters a listening state its “suppose” to fire AddSocket event -_-
Only if it is listening. It could be that the port you’ve chosen is already in use.
Can you show us the code you’re using to set up the MainServerSocket instance?
I Used Drek code
NOTE: I can Connect to my App from my Computer and the App"ServerSocket" is Located on a remote server, I opened that port on the firewall as well.
Ah, unless you run as a super user, you may not be able to listen on ports below 1024. Try something like 8080 and see if that works.
Changed it to Port 5780 it Connects but AddSocket event still not firing… I use this to Connect:
AddSocket doesn’t fire when the socket connects. It fires several times when you call Listen on the ServerSocket to create a pool of sockets ready to be connected to.
Just out of curiosity… what’s the Super of your ClientSocket class?
Actually just looking at the SynchronousTCPSocketExample project, it’s not connecting. Just because you call Socket.Connect, doesn’t mean that it actually does. You’ll notice in that code that the next thing it does is run a while loop:
While Not socket.IsConnected
// check to see if the socket got an error
If socket.LastErrorCode <> 0 Then
Output("Socket Error: " + Str(socket.LastErrorCode))
// poll the socket to let it do it's thing
What you’re seeing is that LastErrorCode gets a value of 103 which means NameResolutionError: “The socket was unable to resolve the address that was specified.”
Have you tried any of this using the IP address instead of the domain name?
Sorry, that screenshot was a bit full of previous tests that did fail, but you will see on line 6 it did connect and closed with 21 Ticks.
Just for anyone new reading this thread Greg Kindly offered to have a look at my project and I’ll be sure to share the solution for anyone in the future having this problem.
I’d like to see the final example on this if you still have it.