|
-
Aug 10th, 2005, 01:39 PM
#1
Thread Starter
Hyperactive Member
winsock help
i put a winsock control on both client and server and named them just Winsock then on the server side i have this code that i got from a sample:
VB Code:
Private Sub Form_Load()
Winsock.LocalPort = 6000
Winsock.Listen
End Sub
Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
Winsock.Close connection
Winsock.Accept requestID End Sub
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim incommingData As String
Winsock.GetData incommingData
txtLogin.Text = incommingData
End Sub
Then on the client side i have this from the other sample..:
VB Code:
Private Sub winsock_connect()
MsgBox "We are connected"
End Sub
Public Sub cmdLogin_Click()
Winsock.RemoteHost = "127.0.0.1"
Winsock.RemotePort = 6000
Winsock.Connect
Winsock.SendData txtLogin.Text
End Sub
Now when I hit "login" i get the message telling me the connection was made but the data doesnt appear to be transferring... i have a text box called txtLogin and it just stays blank.. any ideas?
Last edited by ooOOJaVaOOoo; Aug 10th, 2005 at 02:08 PM.
-
Aug 10th, 2005, 01:51 PM
#2
Fanatic Member
Re: winsock help
Your server is listening on a different port.
VB Code:
Server:
Winsock.LocalPort = 6000
Client:
Winsock.RemotePort = 15151
If that's not the problem, i'm not sure what is...
-Sir Loin
-
Aug 10th, 2005, 02:08 PM
#3
Thread Starter
Hyperactive Member
Re: winsock help
haha thats my bad i was trying different ports and didnt post them with the same ports.. thats doesnt fix it..
-
Aug 10th, 2005, 02:28 PM
#4
Fanatic Member
Re: winsock help
Try adding DoEvents after sending data because sometimes it takes time to send the data accross. Also might want to check to see if winsock is connected.
VB Code:
Public Sub cmdLogin_Click()
Winsock.RemoteHost = "127.0.0.1"
Winsock.RemotePort = 6000
Winsock.Connect
While Winsock.State <> sckConnected
If Winsock.State = sckClosed Then GoTo Cnn_Lost
DoEvents
Wend
Winsock.SendData txtLogin.Text
DoEvents
Winsock.Close
Cnn_Lost:
Winsock.Close
End Sub
-
Aug 10th, 2005, 03:47 PM
#5
Fanatic Member
Re: winsock help
Check to see if both Winsock controls are using the same protocol.
-Sir Loin
-
Aug 11th, 2005, 02:38 PM
#6
Thread Starter
Hyperactive Member
Re: winsock help
nothing seems to be working on this.. all i can do is get the connection.. no data is being sent that i can see.. my goal for this section is to send a username and password to the server and then have it check the login/pw to a database and then if all is ok go ahead and show the next form.. i already have the login/pw authentication work but not through the server side software, just the client connecting straight to the database..
-
Aug 11th, 2005, 02:41 PM
#7
Fanatic Member
Re: winsock help
Are you verifying the connection before sending the data? If not perhaps you're having a timing issue....
-
Aug 11th, 2005, 02:43 PM
#8
Thread Starter
Hyperactive Member
Re: winsock help
i have a message that pops up and notifies that the connection is created
-
Aug 11th, 2005, 02:56 PM
#9
Fanatic Member
Re: winsock help
This just ain't my day for getting my stuff straight the first time....lol
Ok, maybe try adding a DoEvents between the connection and sending of data. With both winsocks running on the same pc you'll probably have to relenquish some CPU cycles.
-
Aug 11th, 2005, 03:18 PM
#10
Thread Starter
Hyperactive Member
-
Aug 11th, 2005, 03:40 PM
#11
Re: winsock help
are you testing these both in the same program or two different programs.
I'd suggest putting them into two different programs so there won't be any blocking issues.
-
Aug 11th, 2005, 03:53 PM
#12
Thread Starter
Hyperactive Member
Re: winsock help
two seperate programs.. is there anyway someone can post a sample of something that might be another way to do what i am trying to accomplish?
-
Aug 11th, 2005, 04:05 PM
#13
Re: winsock help
You can't send data until you're sure you've connected.
try putting the connection request and datasend into two separate buttons, see if that helps
Another way would be to put the sending in the connect event of the client.
-
Aug 11th, 2005, 04:50 PM
#14
Re: winsock help
Here is a working sample. Pino wrote it. 11 downloads so far.
Winsock
-
Aug 12th, 2005, 03:14 AM
#15
Hyperactive Member
Re: winsock help
try putting Winsock.senddata txtLogin.text under Winsock_connect event to make sure that the winsock control is already connected to the server before sending any data.
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
|