Results 1 to 7 of 7

Thread: P2P messaging with winsock

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    61

    P2P messaging with winsock

    hi all, im trying to make a communications tool that will allow me to send instant messages back and forth over winsock... should i either A. do it peer 2 peer and figure out how to get exactt IP address, or should i B. use the server i have as a hub for the messaging? Thanks for any help i can get!

  2. #2
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: P2P messaging with winsock

    C. Use a central server to exchange ip addresses and let the clients do the messaging peer to peer.

    There is no magical way to know the other person's ip address.
    The peers must communicate their ip address through another channel before they can setup a connection.
    This can be a 3rd party route (email, messageboards, smokesignals) or you can provide it.

    Just make the server maintain a table with users and their ip addresses. (like DNS)

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    61

    Re: P2P messaging with winsock

    ok i have a server what would be the best way to setup something like that? ive thought about using iwnsock to capture there IP but ive heard alot of people say that it gets the internal network IP instead of the actualy ISP IP address.. if thats the case how would that function with 2 people on the same network accessing the program? Thanks!

  4. #4
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: P2P messaging with winsock

    That is where the server comes in.

    It can know the client's ip address because the client opens a connection to the server.

    What the server does is listen on port x so that clients can connect to it.
    Once a connection is established the server and client will start exchanging data.
    -The client gives his name and password
    -The server lists who is online
    -The server sends the message of the day
    -Etcetera

    What you need to is define a protocol that the client and server must follow.
    For example: "LOG_ON john qwerty" would signal that john logs on with the password qwerty.
    The server then looks for john in his list of registered users and if the username and password are correct he will list john as "online" and sends back "LOGGED_ON john" to acknowledge the logon.

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    61

    Re: P2P messaging with winsock

    so basically, i setup something like this...

    dim userinfo as string
    userinfo = login.text & password.text
    Client side: sckConnect.send data userinfo

    how would i decode that back into 2 seperate fields for the server to check.

    then it would send back the ok youre in or wrong password string. i think im on the right path?

  6. #6
    Hyperactive Member
    Join Date
    Aug 2006
    Location
    TeXaS
    Posts
    497

    Re: P2P messaging with winsock

    example:
    __clientside__
    userinfo = login.text & "|" & password.text


    __server side__
    VB Code:
    1. Dim LoginArray() As String
    2. LoginArray = Split(userinfo, "|")
    3. If UBound(LoginArray) = 1 Then
    4.     username = LoginArray(0)
    5.     password = LoginArray(1)
    6. Else
    7.     'bad data passed
    8. End If

  7. #7
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: P2P messaging with winsock

    Basically the simplest way to acomplish this task is whit a server using scripts. Create a script on the server (your website) that will get the ip address and store it in a file or database. Your program will pass who it is and the server will gather it's ip address.

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