 |
 |

09-21-2003, 09:08 AM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 16
|
|
Connection is forcefully rejected. ??!!
|
Hi,
I've followed some posts here and manage to make a client/server app.
Now i have a problem :
The server is always running, and the ckient is not. The 1st time the client is used everything is ok, but if i close the client and then open it again i get this error :
Error 10061 Connection is forcefully rejected.
Any ideas?
Thanks
|
|

09-21-2003, 09:16 AM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 16
|
|
|
The server has this :
wsServidor.LocalPort = 10101
wsServidor.Listen
The client has this :
wsCliente.RemoteHost = "127.0.0.1"
wsCliente.RemotePort = 10101
wsCliente.Connect
|
|

09-21-2003, 12:15 PM
|
|
Senior Contributor
|
|
Join Date: Jul 2003
Location: London, England
Posts: 993
|
|
|
Are you telling the server to listen again once the connection has been lost? The error means most of the time that there is nothing listening on that port.
|
|

09-21-2003, 12:35 PM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 16
|
|
|
What you mean.
I start the server. Connect the client. Send the data i need. Server gets it and sends a ok message. Client quits.Servers stays up
If i want to do it again it gives me the error message.
Do i have to "tell" server to continue listen? How do i tell it to listen again?
Thanks for helping me
|
|

09-21-2003, 03:36 PM
|
 |
Retread
Retired Moderator * Expert *
|
|
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,742
|
|
|
When you close the client, do you tell the Winsock to close? If you don't then the server might still be listening because you didn't tell it to stop, resulting in it blocking out your second attempt...
Can you post the code that is giving you this error? (And any other relevant code...)
~Mike
|
|

09-22-2003, 02:51 AM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 16
|
|
|
This is the server code :
-------------------------------------------------------------------
Private Sub Form_Load()
wsServidor.LocalPort = 10101
wsServidor.Listen
End Sub
Private Sub Winsock_ConnectionRequest(ByVal RequestID As Long)
' if the socket is open, we have to close it. This is
' because if you try to use a socket for more than one
' thing at once, it will cause an error.
Winsock.Close
' now we can accept the new connection
Winsock.Accept RequestID
End Sub
Private Sub wsServidor_DataArrival(ByVal bytesTotal As Long)
Dim receiveddata As String
wsServidor.GetData receiveddata, vbString
End Sub
---------------------------------------------------------------------
|
|

09-22-2003, 02:53 AM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 16
|
|
|
If you need the client code just say, and i'll post it.
Thanks for helping out
|
|

09-22-2003, 07:07 AM
|
 |
Contributor
|
|
Join Date: Jan 2002
Location: Penang, Malaysia
Posts: 508
|
|
|
You need to set your Winsock to Listen again after the disconnection.
|
__________________
Nothing is impossible in Programming! So, take it easy and let us all share your problem. :)
|

09-22-2003, 07:39 AM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 16
|
|
Quote: Originally Posted by pinster You need to set your Winsock to Listen again after the disconnection.
How do I do that ?where?
|
|

09-22-2003, 11:32 AM
|
|
Senior Contributor
|
|
Join Date: Jul 2003
Location: London, England
Posts: 993
|
|
|
Put in the winsock_close sub:
winsock.close
winsock.listen
??? reading your code, you have 2 different names for the winsock, it is called Wnsock in the connect sub, but wsServidor in the rest of the subs. This can't work, so check this code to see what the winsock is called.
|
|

09-23-2003, 12:39 AM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 16
|
|
|
That was my mystake when writing it here. In my code is always wsServidor.
Thanks for the help
|
Last edited by phorta; 09-23-2003 at 12:44 AM.
|

09-23-2003, 12:45 AM
|
|
Newcomer
|
|
Join Date: Sep 2003
Posts: 16
|
|
|
Thanks guys.
It works perfect now.
Thanks
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|