Results 1 to 8 of 8

Thread: Help required winsock

  1. #1

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

    Help required winsock

    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

  2. #2
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: Help required winsock

    Are you trying to make an instant messanger type thing?
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  3. #3

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

    Re: Help required winsock

    Basically i am trying to make a software like wise net meeting, where any user can send and receive messages from any user. Client server type chat program is restricted with server only, it does not allow communication with other users on intranet

  4. #4
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177

    Re: Help required winsock

    You will need more than 1 winsock client to do what you are trying to do. ATt the very least you will need a server control and a client control.

    If you will only accept 1 connection at a time, 1 server control will be enough, otherwise you will need an array of server controls. Likewise, if you will only connect to 1 of the other computers at a time then you only need 1 client, otherwise you will need at the most 1 client control for each of the other computers.

    Using your code as an example, I would make changes similar to the following:
    Code:
       wsckServer.LocalPort = 15151
       wsckServer.Listen
    and
    Code:
    If user = 'aa' then
       wsckClient.RemoteHost = "192.168.0.2"
    Else
       If user = "bb" then
          wsckClient.RemoteHost = "192.168.0.3"
       End If
    End If
    wsckClient.RemotePort = 15151
    wsckClient.Connect
    When the server control's connection is closed, don't forget to go back to the listening state so that you can accept the next connect request.

  5. #5
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Help required winsock

    Quote Originally Posted by ccoder
    [code]
    If user = 'aa' then
    wsckClient.RemoteHost = "192.168.0.2"
    Else
    If user = "bb" then
    wsckClient.RemoteHost = "192.168.0.3"
    End If
    End If
    wsckClient.RemotePort = 15151
    wsckClient.Connect
    That is a poor If Statement,

    What it should be is,

    VB Code:
    1. If user = 'aa' then
    2.    wsckClient.RemoteHost = "192.168.0.2"
    3. ElseIf user = "bb" then
    4.       wsckClient.RemoteHost = "192.168.0.3"
    5. End If

    Pino

  6. #6
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177

    Re: Help required winsock

    Quote Originally Posted by Pino
    That is a poor If Statement,

    What it should be is,

    VB Code:
    1. If user = 'aa' then
    2.    wsckClient.RemoteHost = "192.168.0.2"
    3. ElseIf user = "bb" then
    4.       wsckClient.RemoteHost = "192.168.0.3"
    5. End If

    Pino
    True!

    I code in so many languages that sometimes the code looks correct, and then it takes me forever to figure out what is wrong when there is a problem.

  7. #7
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Help required winsock

    No, it would have worked fine just wasnt the ebst way to write it. Dont worry about it

    Pino

  8. #8

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

    Re: Help required winsock

    Besides this how if condition should be applied, i would like to know, that what shoud be port number for each control, is it same for each control or seperate. And also want to know , that as many users on my intranet i have to add such number of control on form, if yes please send me sample code for three users 'aa', 'bb' , 'cc'.

    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
  •  



Click Here to Expand Forum to Full Width