Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Small problem with code


EclipseCommunity
 Share

Recommended Posts

So i've been messing around with Robins networking system in Eclipse Origins 2.0, and decided I wanted to rip it out and use it as a base networking engine for any future projects. Since I'm trying to steer away from MS based engines and write something more original, I thought I could start here (Since I've only been able to write a crappy networking system like MS's, but EO's is faster and more optimised).

So I've taken out as much as I can, and so far I've been able to get the server working nicely, and ping it from an external client.

However, the issue I'm having at the moment is not being able to ping the server with the client I have setup using EO's socket system.
I've set up a dummy login button to try and send a connection to the server. Naturally it won't function and may even error, but as long as the server recieves a connection from the client, that's a starting point.

The code is messy and there's bits floating around which probably aren't even needed yet, but I'll tidy it all up later when I have it working properly.

If anybody could have a gander over the code so far, just see if you can figure out what I'm missing from the client.

Thanks.

**Code:** http://www.draignet.com/hosted/DraigMUD.rar
Link to comment
Share on other sites

A cursory glance at your client code flow reveals that you're calling TcpInit before you set your options in Main.
Note: I'm at work right now, so I don't have VB6, and I'm just reading through the code with some syntax highlighting.

Here is your main routine:
```
Public Sub Main()
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Call TcpInit

    Options.Game_Name = "Eclipse Origins"
    Options.IP = "localhost"
    Options.Port = 7001

    frmMain.Show

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "Main", "modGeneral", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Here is your TcpInit routine:
```
Sub TcpInit()
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Set PlayerBuffer = New clsBuffer

    ' connect
    frmMain.sckSocket.RemoteHost = Options.IP
    frmMain.sckSocket.RemotePort = Options.Port

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "TcpInit", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Notice how TcpInit is called from Main BEFORE you set the IP and Port fields of your Options variable. This means that when the fields are set on the socket, you're using the default values for Options.IP and Options.Port. This means that later once you click your "Connect" button, it's most likely trying to connect to Host "" on Port 0.

Move the call to TcpInit below where you set Options.Port = 7001.
Link to comment
Share on other sites

I used to be very involved in the PW scene until everything started merging into one site and then gradually fading away. I also did some work with Elysium back in the day, but only released like 2-3 tutorials. I was mostly a debugger and general programming knowledge guy.

Haven't really been around for at least 3 years… maybe longer.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...