Results 1 to 5 of 5

Thread: Simple Winsock?

  1. #1

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    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
    <removed by admin>

  2. #2
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Thumbs up 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.

  3. #3

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    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.
    <removed by admin>

  4. #4
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Wink 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]

  5. #5

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    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
    <removed by admin>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width