|
-
Nov 2nd, 2000, 01:23 AM
#1
Thread Starter
PowerPoster
Is there a simple way to use winsock to send text? I want to make a simple program like WinPopUp that comes with windows. I don't want to use graphics or anything, just simple text. I want to make a program that I can give to my friends so that we can chat in my computer class. WinPopUp is too slow when sending messages. I have very little knowledge of the winsock control, so just basics will help me. I tried reading one of the tips on the main part of this site, but it was way too complicated.
Thanks
-
Nov 2nd, 2000, 02:23 AM
#2
Addicted Member
Try this...
this does what you want... no graphics.
'server
Option Explicit
Private Sub Command1_Click()
Winsock1.SendData Text1.Text
End Sub
Private Sub Form_Load()
Winsock1.LocalPort = 1134
Winsock1.Listen
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim IncomingData As String
Winsock1.GetData IncomingData
MsgBox IncomingData
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckConnected Then Winsock1.Close
Winsock1.Accept requestID
Winsock1.SendData "Welcome!!!"
End Sub
'client
Option Explicit
Private Sub Command1_Click()
Winsock1.Connect "any ip here., 1134
End Sub
Private Sub Command2_Click()
Winsock1.SendData Text1.Text
End Sub
Private Sub Winsock1_Connect()
MsgBox "Connected"
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim ClientData As String
Winsock1.GetData ClientData
MsgBox ClientData
End Sub
if it dont werk..then just reply.. i will or someone will correct it.
-
Nov 2nd, 2000, 11:29 AM
#3
Thread Starter
PowerPoster
OK, I got the client and server going, but I get an error saying "Wrong protocol or connection state for the requested transaction or request". what does this mean? It is really confusing me. Thanks to anyone that replies.
-
Nov 2nd, 2000, 08:45 PM
#4
Addicted Member
Ok...
Try setting the protocol property to sckTCPProtocol.
also try this code for both client and server.
Private Sub Form_Unload()
Winsock1.close
End Sub
That way your program will close the sockets... if you dont close them..they will just hang there open waiting for information to enter them..and you will recieve that same error message.
a el cheapo way of getting rid of that problem is to do this at the beginning of the sub routine that has the error in it
"On error resume next"
when you put that command in...it tells vb to ignore what error happens and too continue on it's merrily way 
But i wouldnt recommend doing this unless you have too.
Hope that helps.
[Edited by Sophtware on 11-02-2000 at 08:48 PM]
-
Nov 2nd, 2000, 10:14 PM
#5
Thread Starter
PowerPoster
It still doesn't work. I tried you suggestion, and it still gets the same error. When I put the no skip error code in there, the error didn't show up, but the program still didn't work. I wonder if I am doing it right: I make two forms, one called server and the other called client. On the server, there is a textbox, and a command button. On the client, there is a textbox, and 2 command buttons. Is that how I am supposed to do it?
Thanks
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
|