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

Eclipse Stable Socket Check Error Handle Fix


balliztik1
 Share

Recommended Posts

I'm not sure if the socket check exists in earlier versions, but in Eclipse Stable, it does not do its job. It checks for the wrong error code, and does not put the error catch in the right sub, anyway, so instead of the error handle dealing with the problem, the server just crashes. The problem is here:

```
    ' Error handling for 'Address in use' error
    Err.Clear
    On Error Resume Next

    ' Start listening
    GameServer.StartListening

    ' RTE 10048 occured
    If Err.Number = 10048 Then
        Call MsgBox("The port on this address is already busy.", vbOKOnly)
        End
    End If
```
The problem is twofold. One, StartListening is not a method, but rather a sub within a class. Therefore, any errors with the sub must be caught within that sub, not elsewhere. Secondly, error 10048 does not apply to the socket type used. These sockets use RTE -2147352567(80020009) when an error occurs. So, even if the error occurred here, it wouldn't be caught. The error catching must be placed within the StartListening sub. Find it:

```
Public Sub StartListening()
On Error Resume Next
    m_Server.StartListening

    If Err.Number <> 0 Then
        Call MsgBox("The port on this address is already busy.", vbOKOnly)
        DestroyServer
    End If
End Sub
```
As shown here, this altered sub looks for the correct error number, then handles the destruction of the server. I swapped out End for DestroyServer simply because this is how nearly every other process handles a server shutdown.

All in all, this won't really affect much, since the error handler doesn't exactly do much different than a server crash. However, it should work correctly regardless.
Link to comment
Share on other sites

Yeah, I think it's IOCP. I was actually working on something of my own with Winsock, so I checked out ES and MS4 as reference. When I noticed two different systems were using the same code, I poked around and fixed this minor issue. I don't really want to poke too hard, though.  XD

@[SB:

> Damian666 link=topic=55098.msg583353#msg583353 date=1260259268]
> i didnt touch that, hell, i tried running two servers, and it reports the port in use like it should O.o
>
> Damian666
>
> i thought we were using winsock?

As did I. I forget when it was swapped over, but there's remnants of Winsock code still there. As for the report, the server throws an error. It essentially catches the multiple port issue, but not due to error handling. It just crashes.
Link to comment
Share on other sites

IOCP's better for multithreaded programs, from what I've read, but much more complicated. Plus, if the current system has a memory leak, that's never a good thing. Winsock suits the needs, I suppose. I've never seen it have any problems.

And fixed a lil' bit in the code above. Apparently, the error number can't be specified. It's one of those really weird errors.
Link to comment
Share on other sites

@[SB:

> Damian666 link=topic=55098.msg583362#msg583362 date=1260261138]
> well, cant we replace that custom dll with the normal one?
>
> and ok, ill update the code ^^
>
> Damian666

The .dll Ron edited for Mirage won't work with Mirage. He edited it to allow for your stupidly large string packets which causes a memory leak.

Only use IOCP if you know the theory behind it and you're using byte arrays.
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...