Results 1 to 24 of 24

Thread: [HELP] Winsock problem. Please help me

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    54

    [HELP] Winsock problem. Please help me

    Hi guys,

    I have a game server, that people can connect using winsock indexes. But in another section of the game, the user get disconnect of Winsock Index 1, and get connected to Winsock Index 2

    For example:

    Before closing Winsock Index 1 for accept new users, I would like to CHECK if the same IP that was connected to Winsock INDEX 1 is connected to another winsock index.

    Why do I want it?

    I want to do it because I need to check if that IP, for sure, is not connected to another Winsock Index

    Basically, I want to check if the IP still conected to any Winsock Index.

    The code I use to kill sockets

    Code:
    Public Sub CleanDeadSockets()
    
    Dim intX As Integer
    
    For intX = 1 To 100
        If wsbroker(intX).State = 8 Then
            wsbroker(intX).Close
        End If
        
    Next intX
    
    End Sub
    If you can, help me, please.

    Thank you.
    Last edited by TheMarKs; Jan 30th, 2013 at 05:59 AM.

  2. #2

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    54

    Re: [HELP] Winsock problem. Please help me

    anyone? :s

  3. #3
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: [HELP] Winsock problem. Please help me

    just be patient sir medic will arrive soon

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: [HELP] Winsock problem. Please help me

    That's funny


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: [HELP] Winsock problem. Please help me

    I use a UDT array to store various info about the connections, one of those is the clients IP address. When a connection request comes in I check to see if the IP address is in the list and if so then I reconnect it to the same control it was connected to before.
    When the connection is closed I clear the IP address from the list.

    The only time you should ever get a connection request from the same client is if the connection was broken and the server doesn't know yet or if the client is running more than one instance of the program

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: [HELP] Winsock problem. Please help me

    Example from one of my servers
    Code:
    For X = 1 To RFLic
           If RFBridge(X).IPAddress = Winsock1(0).RemoteHostIP Then
                Winsock1(X).Close
                DoEvents
                Winsock1(X).Accept requestID
                IPStatus = True
                List1.AddItem "Reconnected Channel " & CStr(X) & " to " & RFBridge(X).IPAddress, 0
                Exit For
            End If
        Next
    If IPstatus is false after the loop shown here then the code will loop through the available winsock controls until it finds one that is not in use and use it for the connection

    If there are no more then it will accept on a spare and send a message letting the client know that the server is full and disconnect

  7. #7

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    54

    Re: [HELP] Winsock problem. Please help me

    Thank you DataMiser.

    but i've just had another idea.

    I want to check if the the IP that is connected to Winsock1 is connected to Winsock2 too, how can I do it?

    I thought about do this:

    Code:
    Private Sub Check()
    Dim intX As Integer
    Dim intY as Integer
    
    For intX = 1 To 100 and intY = 1 to 100
        If wsbroker(intX).State = sckConnected Then
            If  NOT wsbroker(intX).RemoteHostIP = Winsock2(intY).RemoteHostIP Then
    wsbroker(intX).Close
    End If
        End If
        
    Next intX
    End Sub
    Last edited by TheMarKs; Jan 31st, 2013 at 06:16 PM.

  8. #8
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: [HELP] Winsock problem. Please help me

    Use an array to handle connections. one index in the array per index in the socket pool.

    I stil don't understand why do you want to handle several pooles of sockets if it is for the same game. You won't gain in performance dividing the crowld in several sockets arrays.

    BUT, if your idea is to have an *FREE* entry, plus a *PAYED* entry, that is not the way, you can do that differentiate in the communication's protocol itself, dropping connections if the client become *free* and he overflows the freeware allowed ammount. In the game screen, you can show a STATs from the server that showed FREE users are 5 of 25 allowed.

    the rest of the pool become available only for PAYED users (users who log in with a payed account).

    Now if you thinks that *FREEs* will flood all SLOTs, well, your server must drop the connections as fast as they has not IDENT. Like, The gamer must write his account BEFORE that the client software try to connect.

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: [HELP] Winsock problem. Please help me

    Not sure what you are trying to do there but keep in mind that you can not rely on the connected state giving you an accurate result.
    If a socket is connected at some point it may show a connected state even though it is no longer connected. The only way to be sure is to try and send data through it.

    While I have never tried to set up an For statement that way I would imagination that it would fail quite badly

  10. #10

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    54

    Re: [HELP] Winsock problem. Please help me

    I have the GAME SOCKET that is working perfectly and another winsock, the anticheat winsock.

    I have an application that works as updater and anticheater.

    I need to be sure that while the user is connected to the game, he is also connected to the anti cheat. You got it?

    Both winsocks are on the same project, and when he open that application, he connect to the anticheat server. Ok. Then he log in to the game and connect to the game winsock. Perfect.

    So if he is only connected to the game winsock, means that he closed the anticheat. Then I will disconnect him from the game.

    The GAME and the ANTICHEATER are different applications.
    Last edited by TheMarKs; Jan 31st, 2013 at 06:30 PM.

  11. #11
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: [HELP] Winsock problem. Please help me

    Then perhaps a nested loop is what you are looking for or maybe not.... are both connections going to be using the same control index or could they be different?

  12. #12
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: [HELP] Winsock problem. Please help me

    as DataMiser stated, you must to check several things in your game protocol.

    * Death connection without ACKs alerting about it (very often on WAN connection), so PING/PONG msgs is mandatory.
    * A way to LogIn, Ident the user.
    * A way to recognize and acept the client software VERSION as valid.
    * A way to be aware of FRAGMENTATION of the information received (concatenate in a buffer, to fetch and to interpret COMPLETED messages ONLY).
    * Design the protocol for be SHORT, easy to write/read message (because you are using VB), but hard to hack. (in other words, don't do all the VALVE's vulneralities, thinking in just latencies, thinks in a smart structure for the communication protocol).
    * Offcourse to handle the communication in strings is the best way, but is BEST to use it in 8bit mode, AscB ChrB MidB instead of Asc Chr Mid. It will use the HALF size for packets.
    * Never do BIG things as response of a message receive, just do some math, some limit comprobations, etc.
    * The rendering of the game has nothing to do with COMMUNICATION, communication must be asyncronous from the SCENE rendering.
    * Player inputs must be handled in asyncronous way nothing to do with SCENE rendering.
    * Use multi-processes (in VB6, do several .EXE running in parallel, that will make a better use of multi-core CPUs, and you can completely separate scene-rendering from input or communication, or Sound rendering).

    DO IT RIGHT and you won't need an anti-cheat at all.
    And there is more tricks in the hat.
    Last edited by flyguille; Jan 31st, 2013 at 06:41 PM.

  13. #13

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    54

    Re: [HELP] Winsock problem. Please help me

    Yeah they could be differente. He can be connected to the game with the index 1, and connected to the anticheat server on index 2. Remember, there are 2 WINSOCKS. I just need to be sure that all the ips connected to the game winsock, are connected to the anticheat server. Otherwise, the game winsock index of that IP must be closed.

  14. #14

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    54

    Re: [HELP] Winsock problem. Please help me

    flyguille, I am not developing the game. I just have created a LOGIN SERVER, based on an existing one. Everything is ok, working perfecty. So then I put a anticheat server, and I just need to be sure that the IP that is connected to the game server, is also connected to the anticheat socket. In this case, SOCKET 1 and SOCKET 2.

    To be short:

    The user cannot be connected to WINSOCK 2 if he is not connected to WINSOCK 1.
    Last edited by TheMarKs; Jan 31st, 2013 at 06:43 PM.

  15. #15
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: [HELP] Winsock problem. Please help me

    Quote Originally Posted by TheMarKs View Post
    flyguille, I am not developing the game. I just have created a LOGIN SERVER, based on an existing one. Everything is ok, working perfecty. So then I put a anticheat server, and I just need to be sure that the IP that is connected to the game server, is also connected to the anticheat socket. In this case, SOCKET 1 and SOCKET 2.

    To be short:

    The user cannot connect to WINSOCK 1 if he is not connected to WINSOCK 2.
    the way sxe-injected (a famous anticheat) works, is to intercept the game's communication, the anticheat inserts messages in an higher protocol (using the game's channel), on the server side, the anticheat software receive those *specials* messages, the rest goes to the game's server, and that way the server side of the anticheat knows, which connections to the game HAVE the current ANTICHEAT running on, they don't need an EXTRA connection.

  16. #16
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: [HELP] Winsock problem. Please help me

    Then you may want to use a nested loop
    Code:
    For X = 1 to 100
       If ' code to test if a client is connected on this socket
            For Y = 1 To 100
                  'Code to check each socket to see if the client is connected here as well
                  'If you find the client is connected to any of them then set a flag and exit the for
            Next
            'code here to test the flag, if flag is false close client(x)
            'reset the flag
       End If
    Next

  17. #17

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    54

    Re: [HELP] Winsock problem. Please help me

    I cannot edit the GAME server, I can only edit the LOGIN SERVER, and this login server can watch the users using a timer, With this timer I will check if all the users connected to the login server winsock, are connected to the anticheat winsock.

  18. #18
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: [HELP] Winsock problem. Please help me

    Quote Originally Posted by TheMarKs View Post
    I cannot edit the GAME server, I can only edit the LOGIN SERVER, and this login server can watch the users using a timer, With this timer I will check if all the users connected to the login server winsock, are connected to the anticheat winsock.
    it is a MU server?

  19. #19

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    54

    Re: [HELP] Winsock problem. Please help me

    Quote Originally Posted by flyguille View Post
    it is a MU server?
    No. It is a GunBound Server.

  20. #20
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: [HELP] Winsock problem. Please help me

    Quote Originally Posted by TheMarKs View Post
    No. It is a GunBound Server.
    Oh I see, GunBound is leaked, hehe, anyway I already desinstalled all sofnyx games, it has some excelent games, but is a pain in the ass upgrade each game in each PC each WEEK they send an update.

  21. #21

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    54

    Re: [HELP] Winsock problem. Please help me

    Thats why the official servers sucks. They need to create new features to incentive the players to buy cash. It is all about money.

    I had an idea:

    I will make the anticheat answer something when the anticheat server send a message. If there is an answer (pre defined by me) the user is connected to the anticheat server. If not, disconnect.

  22. #22
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: [HELP] Winsock problem. Please help me

    Quote Originally Posted by TheMarKs View Post
    Thats why the official servers sucks. They need to create new features to incentive the players to buy cash. It is all about money.

    I had an idea:

    I will make the anticheat answer something when the anticheat server send a message. If there is an answer (pre defined by me) the user is connected to the anticheat server. If not, disconnect.
    that is a bad idea, first it become easy to hack the anticheat, for more cryptografic you do the message, like each clients handle a private key and things like that, (avoiding anything like a prefixed message as response)

    the problem is that when a hack intercept what message is on the anticheat channel, it will replicate the message, then shut down the anticheat process.

    try a variable message

    like

    server sends message = 12345
    client reply = x= 0#+ (12345 *5 / 3 ^ 2) / 65536 : x=x-int(x) ' Getting like the fraction part.
    reply = x *(x*1.5)

    nasty formulas like that and can be a lot more nasty and dificult to comprehend.

    So the cheater is forced to dissamble your EXE for understand what must return

    so not only must be a message as reply, but the correct reply. Also that helps as an anticheat versioning verification.


    Now, the sxe-injected do that, BUUUUUUUUUUUUUUUT , It hid the message deep inside the VALVE's PROTOCOL, so to spot the *message* is VERY HARD, is not the same to see the message in an EMPTY communication channel.
    Last edited by flyguille; Jan 31st, 2013 at 07:19 PM.

  23. #23

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    54

    Re: [HELP] Winsock problem. Please help me

    Yeah, I agree. I will do it.

    and I guess he wont be able to disassemble the anticheater, because I wil crypt it with yoda's crypter. I've never seen a yoda's unpacker.

  24. #24

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    54

    Re: [HELP] Winsock problem. Please help me

    I GOT IT! the way i wanted.

    created a list with the ip adresses currently connected to the anticheat server.

    but now I have an other problem..

    -> I want to set a timer to verify if the ip adress is on the list.

    like ..


    Code:
     If wsbroker(index).RemoteHostIP = List1.Item = False Then ' HERE A NEED TO CHECK IF THE IP IS PRESENT. HOW DO I DO IT?
                Winsock1(X).Close
                End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width