|
-
Aug 3rd, 2005, 03:03 AM
#1
Thread Starter
Hyperactive Member
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
-
Aug 3rd, 2005, 03:24 AM
#2
Fanatic Member
Re: Help required winsock
Are you trying to make an instant messanger type thing?
-
Aug 3rd, 2005, 03:46 AM
#3
Thread Starter
Hyperactive Member
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
-
Aug 3rd, 2005, 08:27 AM
#4
Frenzied Member
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.
-
Aug 3rd, 2005, 11:42 AM
#5
Re: Help required winsock
 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:
If user = 'aa' then
wsckClient.RemoteHost = "192.168.0.2"
ElseIf user = "bb" then
wsckClient.RemoteHost = "192.168.0.3"
End If
Pino
-
Aug 3rd, 2005, 01:45 PM
#6
Frenzied Member
Re: Help required winsock
 Originally Posted by Pino
That is a poor If Statement,
What it should be is,
VB Code:
If user = 'aa' then
wsckClient.RemoteHost = "192.168.0.2"
ElseIf user = "bb" then
wsckClient.RemoteHost = "192.168.0.3"
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.
-
Aug 3rd, 2005, 01:48 PM
#7
Re: Help required winsock
No, it would have worked fine just wasnt the ebst way to write it. Dont worry about it 
Pino
-
Aug 3rd, 2005, 11:31 PM
#8
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|