 |

06-24-2002, 01:38 AM
|
|
|
using winsock control...after connecting to the client and disconect i cant reconnect
|
using the host program i connect to the client program
but after disconnecting from the client program
i cant reconnect to it
i have tested the host program so i know it isnt it
what could be wrong?
heres the client code:
-----------------------------------------------------------
Private Sub Form_Load()
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strIncoming As String
Winsock1.GetData strIncoming
txtMessageBoard.Text = txtMessageBoard.Text & strIncoming & vbCrLf
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Winsock1.Close
End Sub
|
|

06-24-2002, 01:45 AM
|
|
|
|
i think the problem is here
Private Sub Form_Load()
Winsock1.Listen
End Sub
shoul;d be :
Private Sub Form_Load()
Winsock1.LocalPort = 12345
Winsock1.Listen
End Sub
i think..
|
|

06-24-2002, 01:50 AM
|
|
|
|
sorry, i forgot to say ive already added that to the winsock control
so it aint that
ive already connected to the client..then i disconnect, then reconnect is the problem
|
|

06-24-2002, 06:14 AM
|
 |
ISearchGoogle
Retired Moderator * Expert *
|
|
Join Date: May 2001
Location: england
Posts: 6,321
|
|
You have to make sure that both sides reset their sockets back to their original states.
On the server side, watch the the _Close and _Error events.
Code:
Private Sub Server_Error(ByVal Number As Integer, Description As String, _
ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, _
ByVal HelpContext As Long, CancelDisplay As Boolean)
' reset the socket
Server.Close
Server.Listen
End Sub
Private Sub Server_Close()
' reset the socket
Server.Close
Server.Listen
End Sub
This should reset the server socket so that whenever it closes, it automatically relistens.
|
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
|

06-24-2002, 09:23 AM
|
|
|
|
what about the client side?
|
|

06-24-2002, 09:45 AM
|
|
Senior Contributor
|
|
Join Date: Oct 2001
Location: North Carolina of the U.S.A.
Posts: 1,008
|
|
|
I'm confused. In your original post you have the client form
listening for connection? Isn't that the server form then? I
may be wrong again, though.
It seems on your client form, you should make it re-listen
when it closes. But on your server form, it should just say
it is closed. I don't think it is right for it to automatically try to
reconnect.
|
__________________
Search the forums if time permits and use the [vb][/vb] tags to put VB code in your post.
|

06-24-2002, 10:06 AM
|
 |
ISearchGoogle
Retired Moderator * Expert *
|
|
Join Date: May 2001
Location: england
Posts: 6,321
|
|
|
Let's just be clear about terminology.
Server is the one that listens, that serves up stuff to the client.
Client is the one that connects to the server, in order to retrieve stuff.
|
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
|

06-24-2002, 05:37 PM
|
|
|
|
Sorry I got the server and client mixed up.
I mean ...I dont think the ports reopening after i close it
I tried added winsock1.listen
but it wwont let me run it twice
|
|

06-24-2002, 05:52 PM
|
|
Senior Contributor
|
|
Join Date: Oct 2001
Location: North Carolina of the U.S.A.
Posts: 1,008
|
|
You don't think it is, or you don't want it to?
If you can't listen twice, check first to see if it is listening...
Code:
If winsock1.state <> sckListening then
winsock1.close
winsock1.listen
end if
|
__________________
Search the forums if time permits and use the [vb][/vb] tags to put VB code in your post.
|

06-25-2002, 05:41 AM
|
|
|
|
thanx agent
i was just curious tho
before when it wasnt working
the winsock state would be 8
not 7 "listening"
i looked 8 up and its nothing
anyone know what this is?
|
|

06-25-2002, 05:47 AM
|
 |
Political Coder
Retired Moderator * Guru *
|
|
Join Date: Mar 2001
Location: London, England
Posts: 8,037
|
|
|
If you search the F2 Object Browser for StateConstants you'll find that 8 is sckClosing - Socket is closing connection to a remote computer
|
|
|
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
|
|
|
|
|
|