Results 1 to 19 of 19

Thread: Socket problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Location
    South Carolina
    Posts
    31

    Socket problem

    I havent developed an VB6 Application that uses Sockets in a long time.

    But anyway, I'm working on one atm and for some reason the Socket connects to the server every 1 in 5 tries. Now I think this might be some XP SP2 [removed by mod]. Does anyone have any idea?

    BTW: Running this Server/Client app on same computer for testing. And I do have VB6 SP6 installed.

    Thanks for the Help
    Carsten
    Last edited by Pino; Mar 14th, 2005 at 03:43 PM. Reason: edited language

  2. #2
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796

    Re: Socket problem

    I had a similar issue. Turned out to be Norton Antivirus. I replaced it with NOD32 antivirus and everything worked fine. Possibly there is a configuration work around, but it was faster to change it.
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Socket problem

    Quote Originally Posted by Carsten
    I havent developed an VB6 Application that uses Sockets in a long time.

    But anyway, I'm working on one atm and for some reason the Socket connects to the server every 1 in 5 tries. Now I think this might be some XP SP2 bull****. Does anyone have any idea?

    BTW: Running this Server/Client app on same computer for testing. And I do have VB6 SP6 installed.

    Thanks for the Help
    Carsten
    Are we talking winsock? Also please watch the language

    Pino

  4. #4
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Re: Socket problem

    I have had LOADS of trouble with winsock in SP6. I dont even use SP6 anymore but it might just be me
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  5. #5
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177

    Re: Socket problem

    Quote Originally Posted by Carsten
    I havent developed an VB6 Application that uses Sockets in a long time.

    But anyway, I'm working on one atm and for some reason the Socket connects to the server every 1 in 5 tries. Now I think this might be some XP SP2 bull****. Does anyone have any idea?

    BTW: Running this Server/Client app on same computer for testing. And I do have VB6 SP6 installed.

    Thanks for the Help
    Carsten
    Can you post the client's connect code? Are you setting the LocalPort to some value?

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Location
    South Carolina
    Posts
    31

    Re: Socket problem

    Yeah, we are talking about Winsock Sp6 in Windows Xp sp2.

    Yes, the loca port is set properly. I have done many server/client applications and never had problems. And Imnot using a firewall

  7. #7
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Re: Socket problem

    Have you tried disabling your antivirus (As well as the firewall) I have found some AV software seems to lock down new apps if they are acting suspicious
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Location
    South Carolina
    Posts
    31

    Re: Socket problem

    No firewall/antivirus running . Havent tried downgrading to VB6 SP5 but that might be the issue. I'll check up on it and let u know

  9. #9
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Socket problem

    is it possible for you to post your code?

    There may be a problem we can fix?

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Location
    South Carolina
    Posts
    31

    Re: Socket problem

    Server Code for Server: (Port 999)

    Code:
    Private Sub Socket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    
        'Declares Memory Variables
        Dim lngA As Long
        Dim strRemoteIP As String
    
        'Sets Variables
        strRemoteIP = Socket(Index).RemoteHostIP
        
        'Checks If IP's banned
        If IsBanned(strRemoteIP) = True Then Exit Sub
        
        'Loops through each Socket
        For lngA = 1 To Socket.UBound
        
            'Checks for Free Socket
            If Socket(lngA).State <> 7 Then
            
                'Closes Socket
                Socket(lngA).Close
                Socket(lngA).Accept requestID
                
                'Removes All Data from SubSocket
                Call DumpSubSocket(Index)
                
                'Ends Execution
                Exit Sub
                
            End If
        Next lngA
        
        'Finds Upper Bound of Socket plus one
        lngA = Socket.UBound + 1
        
        'Removes All Data from SubSocket
        ReDim SubSocket(lngA)
        Call DumpSubSocket(CInt(lngA))
        
        'Loads New Socket
        Load Socket(lngA)
        Socket(lngA).Close
        Socket(lngA).Accept requestID
        
    End Sub
    And the client part is pretty streight forward.

    Code:
            'Attempts to Connect to Central Data Server
            frmMain.SocketT2A.Close
            frmMain.SocketT2A.Connect "127.0.0.1", 999
    Again, it connects fine. Then I close the application (in VB IDE) and relaunch it b/c I changed something and it doesnt work. Then, if I give it a few minutes and run the exact same code it does work. Kind of odd to me. As for the programming, I do know what I'm doing so that shouldnt be a problem.

    Also on the server side; it doesnt banned anyone yet. So that shouldnt effect anything. I would release all the code but I cant

  11. #11
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177

    Re: Socket problem

    Quote Originally Posted by Carsten
    Again, it connects fine. Then I close the application (in VB IDE) and relaunch it b/c I changed something and it doesnt work. Then, if I give it a few minutes and run the exact same code it does work. Kind of odd to me. As for the programming, I do know what I'm doing so that shouldnt be a problem.

    Also on the server side; it doesnt banned anyone yet. So that shouldnt effect anything. I would release all the code but I cant
    You are setting the port (999) rather than allowing the system to select one that isn't busy. The port will remain in the TIME_WAIT state for about 4 minutes after the connection is closed. This is why I asked you if you were setting the port to some value in my earlier post. You assured us that you had "done many server/client applications and never had problems". I didn't persue the issue.

    Set the port to zero before connecting and let the system decide which one to use.

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Location
    South Carolina
    Posts
    31

    Re: Socket problem

    I dont understand here.

    On the server I have to tell it what PORT to listen too, it has to be. And the on the client when I connect, I have to know what port to connect to otherwise it will attempt to connect to a port that isnt open or in use from another application.

    So yeah, I either miss understood you or we arent on the same page b/c what you are sayin I have NEVER heard of before. And I do assured you that "I've done many server/client applications and never had problems". Please correct me if I'm wrong .

    BTW: If I let the "system" decide what port to use, how would the clients know what port to connect if its diffrent all the time?

    Carsten

  13. #13
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177

    Re: Socket problem

    Sorry, I'm having a bad day. Somehow I misread your code.

    You have to set the client's RemotePort to the port number that the server is listening on - I assume that it is 999. Set the client's LocalPort to zero and the system will select an unused port number for you.

  14. #14
    Member
    Join Date
    Feb 2005
    Location
    Usa Nyc
    Posts
    45

    Re: Socket problem

    I haven't coded sockets in vb in a while but doesnt the remotehostip property get filled out after the host accepts the connection?
    Kiss, Aerosmith, Black Sabbath, Nazareth, Judas Priest, Status Quo, Cinderella, Scorpions, Tool, SteppenWolf.

  15. #15
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Re: Socket problem

    Try this it might not work but its worth a try

    VB Code:
    1. Private Sub Socket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    2.  
    3.     'Declares Memory Variables
    4.     Dim lngA As Long
    5.     Dim strRemoteIP As String
    6.  
    7.     'Sets Variables
    8.     strRemoteIP = Socket(Index).RemoteHostIP
    9.    
    10.     'Checks If IP's banned
    11.     If IsBanned(strRemoteIP) = True Then Exit Sub
    12.    
    13.     'Loops through each Socket
    14.     For lngA = 1 To Socket.UBound
    15.    
    16.         'Checks for Free Socket
    17.         If Socket(lngA).State <> 7 Then
    18.        
    19.             'Closes Socket
    20.             Socket(lngA).Close
    21.             Socket(lngA).localport = 0
    22.             Socket(lngA).Accept requestID
    23.            
    24.             'Removes All Data from SubSocket
    25.             Call DumpSubSocket(Index)
    26.            
    27.             'Ends Execution
    28.             Exit Sub
    29.            
    30.         End If
    31.     Next lngA
    32.    
    33.     'Finds Upper Bound of Socket plus one
    34.     lngA = Socket.UBound + 1
    35.    
    36.     'Removes All Data from SubSocket
    37.     ReDim SubSocket(lngA)
    38.     Call DumpSubSocket(CInt(lngA))
    39.    
    40.     'Loads New Socket
    41.     Load Socket(lngA)
    42.     Socket(lngA).Close
    43.     Socket(lngA).localport = 0
    44.     Socket(lngA).Accept requestID
    45.    
    46. End Sub

    VB Code:
    1. 'Attempts to Connect to Central Data Server
    2.         frmMain.SocketT2A.Close
    3.         frmMain.SocketT2A.localport = 0
    4.         frmMain.SocketT2A.Connect "127.0.0.1", 999
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Location
    South Carolina
    Posts
    31

    Re: Socket problem

    @BodwadUK

    Tried it, didnt help anything. Anyone else got any other suggestions?

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Location
    South Carolina
    Posts
    31

    Re: Socket problem

    Just uninstalled Sp6 and put Sp5 back up...but still same problem.

    I have no clue what the problem is

  18. #18
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Re: Socket problem

    Have you disabled the default windows XP firewall?

    It is very strange but then it is XP
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  19. #19

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Location
    South Carolina
    Posts
    31

    Re: Socket problem

    yeah its off, checked again to make sure, but its off

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