|
-
Mar 9th, 2005, 08:44 PM
#1
Thread Starter
Junior Member
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
-
Mar 11th, 2005, 02:12 AM
#2
Fanatic Member
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)
-
Mar 11th, 2005, 02:40 AM
#3
Re: Socket problem
 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
-
Mar 11th, 2005, 03:21 AM
#4
KING BODWAD XXI
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
-
Mar 11th, 2005, 09:35 AM
#5
Frenzied Member
Re: Socket problem
 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?
-
Mar 11th, 2005, 03:01 PM
#6
Thread Starter
Junior Member
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
-
Mar 14th, 2005, 03:11 AM
#7
KING BODWAD XXI
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
-
Mar 14th, 2005, 03:11 PM
#8
Thread Starter
Junior Member
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
-
Mar 14th, 2005, 03:36 PM
#9
Re: Socket problem
is it possible for you to post your code?
There may be a problem we can fix?
-
Mar 14th, 2005, 07:55 PM
#10
Thread Starter
Junior Member
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
-
Mar 14th, 2005, 08:16 PM
#11
Frenzied Member
Re: Socket problem
 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.
-
Mar 14th, 2005, 10:04 PM
#12
Thread Starter
Junior Member
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
-
Mar 14th, 2005, 11:01 PM
#13
Frenzied Member
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.
-
Mar 14th, 2005, 11:16 PM
#14
Member
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.
-
Mar 15th, 2005, 03:11 AM
#15
KING BODWAD XXI
Re: Socket problem
Try this it might not work but its worth a try
VB 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).localport = 0
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).localport = 0
Socket(lngA).Accept requestID
End Sub
VB Code:
'Attempts to Connect to Central Data Server
frmMain.SocketT2A.Close
frmMain.SocketT2A.localport = 0
frmMain.SocketT2A.Connect "127.0.0.1", 999
-
Mar 15th, 2005, 06:52 PM
#16
Thread Starter
Junior Member
Re: Socket problem
@BodwadUK
Tried it, didnt help anything. Anyone else got any other suggestions?
-
Mar 15th, 2005, 07:23 PM
#17
Thread Starter
Junior Member
Re: Socket problem
Just uninstalled Sp6 and put Sp5 back up...but still same problem.
I have no clue what the problem is
-
Mar 16th, 2005, 03:34 AM
#18
KING BODWAD XXI
Re: Socket problem
Have you disabled the default windows XP firewall?
It is very strange but then it is XP
-
Mar 16th, 2005, 02:53 PM
#19
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|