|
-
Sep 2nd, 2006, 11:07 PM
#1
Thread Starter
Member
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!
-
Sep 2nd, 2006, 11:40 PM
#2
Frenzied Member
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)
-
Sep 3rd, 2006, 12:08 AM
#3
Thread Starter
Member
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!
-
Sep 3rd, 2006, 12:28 AM
#4
Frenzied Member
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.
-
Sep 3rd, 2006, 12:49 AM
#5
Thread Starter
Member
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?
-
Sep 3rd, 2006, 01:27 AM
#6
Hyperactive Member
Re: P2P messaging with winsock
example:
__clientside__
userinfo = login.text & "|" & password.text
__server side__
VB Code:
Dim LoginArray() As String
LoginArray = Split(userinfo, "|")
If UBound(LoginArray) = 1 Then
username = LoginArray(0)
password = LoginArray(1)
Else
'bad data passed
End If
-
Sep 3rd, 2006, 02:52 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|