TCPSockets, error 103

Hello all, I have been looking at different code (matlab, java, c++) until I finally arrived to Xojo mainly because of the multi platform characteristic. I am trying to program a software to teach my students some Game Theory, as what is on line does not comply my requirements.

For that I started studying the good-easy to read- guide that it is posted here . I was trying to establish some communication between a “Server (me, the teacher)” and the students “clients”, so the first thing I wanted was to set up a communication, and after exploring the net, I saw that TCPSocket could be added very simply to the interfaces. I moved forward but I was failing at every attempt, so I decided to go back to the guide above and review chapter 11.

I just wrote down the code in the first example (connect to google.com) but including an error message to check if everything was going fine, and to my surprise, it failed systematically, not only with Google, but with any other address I tried. I even tried with “localhost” but I am not sure if it was supposed to work. I think it might the case that the network (or system) in which I am operating could be the responsible:

Computer is Linux Mint 17.2 64 bits, but Xojo is running in a Virtual Machine (VBox) with Windows 7 64 bits. It runs just fine, and all the Internet connections have been set up (so Windows in the VM can update itself, Office365 got installed beautifully, etc). The host runs through a Proxy (the University proxy), but it has been configured properly, so the computer has plain access to the Internet.

Finally if through the “cmd” in Windows 7 (VM) I ping google.com or google.pt (I’m in Portugal) I got “timed out”, while if I ping “localhost” I got the normal “<0.1ms” ping.

Thanks for any help you can give me!

With Xojo gets installed many examples programs.
If you need a working example for socket connections please look at “Communication\Internet”.

Hi, I did, but those do not work either, (the SocketClient and SocketServer example programs). I think the problem might by in my software or because I’m running behind a proxy, not really in the code. Have you have any problem like these? is there any chance to test as “localhost” way to avoid any “network” interacion, at least while I’m testing the client and server in the same machine?

Thanks

The docs for error 103 say “Name resolution error”.
Please, try “127.0.0.1” instead of “localhost”.

You can also check for name resolution using the example code in http://documentation.xojo.com/index.php/Network

Thanks! this really made me move forward. I can actually recover the IPs of the Addresses (I did for Wikipedia as the example and google.com). This changes and is stable for each. I will try to make a TCPSocket connection, according to the example above, using the “checked” IP from this function.

Best!

UPDATE: Ok, I still cannot connect with “TPCSocket”, I will write down the code here:

Only one button, which in “Action” handle has:

  Dim IPAddress As String
  
  IPAddress = System.Network.LookupIPAddress("wikipedia.org")
  If IPAddress <> "" Then
    MsgBox(IPAddress)
  Else
    MsgBox("An error occurred")
  End If
  
  if System.Network.IsConnected then
    MsgBox "you're online!"
  else
    MsgBox "You're not connected."
  end if
  
  TCPSocket1.Port=80
  TCPSocket1.Address=IPAddress
  TCPSocket1.Connect

TCPSocket1 socket has:

Connected Handle:

MsgBox("Connected!")

Error Handle:

MsgBox("Error"+str(Me.LastErrorCode))

What I receive after clicking in the button : the correct address of wikipedia (91.198.174.192), a “you’re online” message box and then after a while a “Error103” messagebox.

This is puzzling

I think that your virtual machine has an incomplete network configuration.

Tested now, for localhost it says → 127.0.0.1 just as you said.

I tried to run Xojo on my Linux Mint but did not worked (although it did in my laptop, also with Mint 17.2 although very slowly and after installing the 32bit libs). I will try to reinstall it on Mint again and I will give some news, I really appreciate the time you have taken for this, thanks.

Your example works fine here.

What kind of project are you creating (desktop/console…)?

Desktop project, in a window.

Please,
look at the network interface type you assigned to your virtual machine.
Maybe you are using a local network between host and virtual machine only: in this case please set the network interface type to NAT or bridged.

You may want to try this exercise with an httpsocket. It may be that Wikipedia doesn’t allow connections on port 80 by anything that doesn’t identify itself as a browser or a bot.

If you use a browser, does typing “wikipedia.org” on that vm get you anywhere?

@Maurizio Rossi : I do have the network of the VM as bridged. Now I managed to install Xojo in Linux Mint directly (so no more Virtual Machine), and I still receive the Error103. I really think that maybe the proxy thing could be the issue.

@Greg O’Lone : I tried another websites as well (google, my university homepage and localhost) with the same results.

Thanks

UPDATE: I desisted trying with Google, as if I run the “ping” on the terminal will take forever (so It does not let me ping it). Instead I am trying with the school’s main website, that I can successfully ping (as I also can with localhost). Both can be Ping(ed) and give the Error103 through the program.

Try, if possible, outside the school’s network: maybe this it’s the source of the problem.

As stated before, your example here works as expected: connects ok and, as expected, after some time I get error 102 (not 103) i.e. wikipedia.org disconnect the apps because no http request it’s sent.

Regards.

Thanks, I will try to run this out of the University and I will tell you if that solved the problem.

Many Thanks!

UPDATE: Definitively is a problem of the network (or the computer), as I programmed a simple chat (server-client) in Python and it does not communicate as it should (so no client - server communication) using sockets. I do not know, though, why the network is a problem if I am running with the 127.0.0.1 theoretically I never go to any network (outside the computer).

I am back here just to thank you again for your help, and to tell you that in my home computer, this runs perfectly for any IP that is not localhost (or 172.0.0.1). I cannot understand what is behind the problems here, further than the proxy of the school at and that the TCPSocket cannot be used pointing to the same machine, which will difficult my testing process. Nevertheless I am one step closer to my goal.

Best