Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Communications > Connection is forcefully rejected. ??!!


Reply
 
Thread Tools Display Modes
  #1  
Old 09-21-2003, 09:08 AM
phorta phorta is offline
Newcomer
 
Join Date: Sep 2003
Posts: 16
Default 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
Reply With Quote
  #2  
Old 09-21-2003, 09:16 AM
phorta phorta is offline
Newcomer
 
Join Date: Sep 2003
Posts: 16
Default

The server has this :
wsServidor.LocalPort = 10101
wsServidor.Listen

The client has this :
wsCliente.RemoteHost = "127.0.0.1"
wsCliente.RemotePort = 10101
wsCliente.Connect
Reply With Quote
  #3  
Old 09-21-2003, 12:15 PM
samr samr is offline
Senior Contributor
 
Join Date: Jul 2003
Location: London, England
Posts: 993
Default

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.
Reply With Quote
  #4  
Old 09-21-2003, 12:35 PM
phorta phorta is offline
Newcomer
 
Join Date: Sep 2003
Posts: 16
Default

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
Reply With Quote
  #5  
Old 09-21-2003, 03:36 PM
MikeJ's Avatar
MikeJ MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,742
Default

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
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #6  
Old 09-22-2003, 02:51 AM
phorta phorta is offline
Newcomer
 
Join Date: Sep 2003
Posts: 16
Default

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
---------------------------------------------------------------------
Reply With Quote
  #7  
Old 09-22-2003, 02:53 AM
phorta phorta is offline
Newcomer
 
Join Date: Sep 2003
Posts: 16
Default

If you need the client code just say, and i'll post it.

Thanks for helping out
Reply With Quote
  #8  
Old 09-22-2003, 07:07 AM
pinster's Avatar
pinster pinster is offline
Contributor
 
Join Date: Jan 2002
Location: Penang, Malaysia
Posts: 508
Default

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. :)
Reply With Quote
  #9  
Old 09-22-2003, 07:39 AM
phorta phorta is offline
Newcomer
 
Join Date: Sep 2003
Posts: 16
Default

Quote:
Originally Posted by pinster
You need to set your Winsock to Listen again after the disconnection.



How do I do that ?where?
Reply With Quote
  #10  
Old 09-22-2003, 11:32 AM
samr samr is offline
Senior Contributor
 
Join Date: Jul 2003
Location: London, England
Posts: 993
Default

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.
Reply With Quote
  #11  
Old 09-23-2003, 12:39 AM
phorta phorta is offline
Newcomer
 
Join Date: Sep 2003
Posts: 16
Default

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.
Reply With Quote
  #12  
Old 09-23-2003, 12:45 AM
phorta phorta is offline
Newcomer
 
Join Date: Sep 2003
Posts: 16
Default

Thanks guys.
It works perfect now.
Thanks
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
multi connections, one port? burningodzilla Communications 5 08-02-2005 05:04 PM
Forcefully rejected BeNjI Communications 5 09-20-2003 02:05 PM
Connection Forcefully Rejected AOL 8 camaross Communications 1 06-12-2003 02:23 PM
How to clean up after global ADO Connection???? ChubbyArse Database and Reporting 0 03-10-2003 06:56 AM
Checking for Internet Connection rajbly Communications 1 09-02-2002 07:19 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->