|
-
Nov 30th, 2005, 04:58 AM
#1
Thread Starter
Frenzied Member
winsock question
im making the client connect to the port on the ip (as the server is already listening on the same port for incoming connections)
VB Code:
Private Sub cmdConnect_Click()
WStcpClient.Close
WStcpClient.RemoteHost = txtServerIp.Text
WStcpClient.RemotePort = 15000
WStcpClient.Connect
End Sub
but sometimes it doesnt work on the first click of the button, i usually need to close the form, click the button again and then it connects, can someone give me any error checking code so i can print something like
'Unable to connect to server, please try again'
-
Nov 30th, 2005, 02:36 PM
#2
Frenzied Member
Re: winsock question
The real question is "why can't you reconnect?". You should be able to reconnect at any time (unless the server has a single winsock control and it is connected to another client when you try to reconnect).
Can you post/upload all of your code?
-
Nov 30th, 2005, 03:33 PM
#3
Thread Starter
Frenzied Member
Re: winsock question
im using my ip as the server, and clients conect to me
VB Code:
'client side code..
Private Sub WStcpClient_Connect()
WStcpClient.SendData "sendt;" & txtNick.Text
End Sub
'serverside code
If Left(msg, 5) = "sendt" Then
Dim incomingMsg() As String
incomingMsg = Split(msg, ";")
username = incomingMsg(1)
users(Index) = incomingMsg(1)
WStcpServer(Index).SendData "topic" & topic & username
End If
as you see on successfull connection, the server sends the topic to the client, but sometimes the client doesnt get no topic,
-
Dec 6th, 2005, 06:27 PM
#4
Addicted Member
Re: winsock question
VB Code:
WStcpClient.SendData "sendt;" & txtNick.Text
should be:
VB Code:
WStcpClient.SendData "sendt" & ";" & txtNick.Text
server:
VB Code:
If Left$(msg, 5) = "sendt" Then
Dim incomingMsg() As String
incomingMsg = Split(msg, ";", Len(msg))
username = incomingMsg(1)
users(Index) = incomingMsg(1)
WStcpServer(Index).SendData "topic" & topic & username
End If
correct?
but why are you assigning both username and users to 1?
-
Dec 7th, 2005, 01:57 PM
#5
Frenzied Member
Re: winsock question
Pouncer:
I put off responding to your last reply because I was somewhat frustated by its lack of content. What part of "Can you post/upload all of your code?" wasn't clear? We can't help you if you don't provide us with the requested information.
Aphex:
Please explain why you feel that
 Originally Posted by Aphex
VB Code:
WStcpClient.SendData "sendt;" & txtNick.Text
should be:
VB Code:
WStcpClient.SendData "sendt" & ";" & txtNick.Text
Either way, the end results are identical.
And, as for your question
but why are you assigning both username and users to 1?
It's not uncommon to store a value in 2 or more places.
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
|