Results 1 to 2 of 2

Thread: How to send and receive message in single form and with two winsock Controls

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Pakistan
    Posts
    436

    How to send and receive message in single form and with two winsock Controls

    Dear friends

    I want to develope a single form which can perform as local and remote host simultaneously, is it possible if yes then please tell me how. Basically what i am doing, that i set winsock.localport = 15151 and winsock.listen on form load event.

    when any user want to send message to any other user i wrote these code

    if user = 'aa' then
    winsock.remotehost = "192.168.0.2"
    if user = "bb" then
    winsock.remotehost = "192.168.0.3"
    endif
    winsock.remoteport = 15151
    winsock.connect

    it is not working , where i am mistaking
    Last edited by zubairkhan; Aug 3rd, 2005 at 05:52 AM.

  2. #2
    Member
    Join Date
    Dec 2004
    Posts
    49

    Re: How to send and receive message in single form and with two winsock Controls

    I don't know why it doesn't work, because I haven't seen your code, but this works :
    Add 2 command buttons and 2 winsock controls to a form and paste the following code :

    VB Code:
    1. Private Sub Command1_Click()
    2.     Winsock2.Connect "192.168.0.2", 11151  '' local IP address
    3. End Sub
    4.  
    5. Private Sub Command2_Click()
    6.     Winsock2.Close
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10.     Winsock1.LocalPort = 1151
    11.     Winsock1.Listen
    12. End Sub
    13.  
    14. Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    15.     Winsock1.Close
    16.     Winsock1.Accept requestID
    17. End Sub
    18.  
    19. Private Sub Winsock2_Connect()
    20.     MsgBox "Success"
    21. End Sub

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