Results 1 to 10 of 10

Thread: Winsock , Help!!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    15

    Winsock , Help!!!!

    hello , this is the first time i come here , i m checking the website hours ago :P it's really gr8 keep the good work guys
    i m a vb beginner i m using vb6 and i start using winsock latly (minutes ago)
    i read some tutorials on the net and i made this little program but the problem is that it's not working :S . here the code
    thanks in advance

    Private Sub Command1_Click()
    host = InputBox("Enter the host's computer name or ip address:")
    Port = InputBox("Enter the host's port to connect to:")
    Winsock1.Connect host, Port
    End Sub

    Private Sub Command2_Click()
    Port = InputBox("What port do you want to host on?")
    Winsock1.LocalPort = Port
    Winsock1.Listen
    End Sub

    Private Sub Command3_Click()
    Text = InputBox("Send what text?")
    Winsock1.SendData Text
    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)
    If Winsock1.State <> sckClosed Then Winsock1.Close
    Winsock1.Accept RequestID
    End Sub
    Private Sub winsock1_RecieveData(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.GetData Data
    MsgBox Data
    End Sub

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Winsock , Help!!!!

    Edit your post and add VBCODE tags so your code will be much more readable.

  3. #3
    Lively Member
    Join Date
    May 2001
    Location
    UK
    Posts
    83

    Re: Winsock , Help!!!!

    You cannot tell winsock to listen on a port then tell the same winsock to connect to itself.

    Have a look at the sample project i've done for you, no fancy stuff at all.
    Attached Files Attached Files

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    15

    Re: Winsock , Help!!!!

    Thanks Spiv problem solved
    this is the first time i use winsock other than localhostname and ip :P it looks really cool . i have a little question about sending files by winsock , can i send files in ole to another user ?

  5. #5
    Lively Member
    Join Date
    May 2001
    Location
    UK
    Posts
    83

    Re: Winsock , Help!!!!

    Get the attachment, it's not brilliant code but it does show you how to send files through winsock to give you an idea.
    Attached Files Attached Files

  6. #6

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    15

    Re: Winsock , Help!!!!

    woow , the last one was gr8 winsock rocks i didn't understand the whole codes about sending the file but i saw how it works , i m still new in vb i start months ago . anyway i m trying to make a little lan chat room i tried to add both codes of sender and receiver to the same one using 2 winsock , but the problem was that i added 2 commands to the same button winsock1.connect... and winsock2.localhost... i got an error , i want it to send and received at the same time i got always the same error

  7. #7

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    15

    Re: Winsock , Help!!!!

    i changed the project , i don't have that error any more , but it's simply not working , here's the file
    Attached Files Attached Files

  8. #8
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Re: Winsock , Help!!!!

    dont use timers

    use the _Connected event, it gets fired when connected
    use the _Error event, it gets fired when its unabled to connect to server
    use the _Close event, it gets fired when the server closes the client connection

  9. #9

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    15

    Re: Winsock , Help!!!!

    didn't get it :S

  10. #10

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    15

    Re: Winsock , Help!!!!

    i found the error , i m connecting to my self and that connection only accept 1 receiver how can i let it accept many? here's the project
    Attached Files Attached Files

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