Click to See Complete Forum and Search --> : Am i right?
netpumber
Jul 6th, 2007, 07:48 AM
i have code this 2 min ago and i want to ask if this code is right.
I try to make a client that opens a port and the server connect to this port.(reverse connection)
Client:
Option Explicit
Private Sub client_ConnectionRequest(ByVal requestID As Long)
client.Protocol = sckTCPProtocol
client.Accept requestID
End Sub
Private Sub Command1_Click()
client.Listen
End Sub
Private Sub Form_Load()
client.LocalPort = "5500"
End Sub
Public Sub client_connect()
MsgBox "connected "
End Sub
Server:
Option Explicit
Private Sub Form_Load()
server.RemoteHost = "http://n3tpum63r.homedns.org/"
server.RemotePort = "5500"
server.Connect
End Sub
Private Sub server_Click()
server.Protocol = sckTCPProtocol
End Sub
IS this code correct?Thanx again ;)
Hack
Jul 6th, 2007, 09:38 AM
With just a quick glance it looks Ok.
Have you run it? Does it work?
netpumber
Jul 6th, 2007, 10:55 AM
I have run it but it doesn't give the msg box.
Hack
Jul 6th, 2007, 11:25 AM
I don't see where you are calling it.
Do you get any errors?
DigiRev
Jul 6th, 2007, 12:29 PM
i have code this 2 min ago and i want to ask if this code is right.
I try to make a client that opens a port and the server connect to this port.(reverse connection)
Client:
Option Explicit
Private Sub client_ConnectionRequest(ByVal requestID As Long)
client.Protocol = sckTCPProtocol
client.Accept requestID
End Sub
Private Sub Command1_Click()
client.Listen
End Sub
Private Sub Form_Load()
client.LocalPort = "5500"
End Sub
Public Sub client_connect()
MsgBox "connected "
End Sub
Server:
Option Explicit
Private Sub Form_Load()
server.RemoteHost = "http://n3tpum63r.homedns.org/"
server.RemotePort = "5500"
server.Connect
End Sub
Private Sub server_Click()
server.Protocol = sckTCPProtocol
End Sub
IS this code correct?Thanx again ;)
There's quite a few things you should change. You specified LocalPort as a string when it's an integer. You put the msgbox code in the client_connect() event. It should be in the ConnectionRequest() event after the .Accept RequestID line. The connect() event only triggers when you establish a remote connection, not when someone connects to you.
On the server, you're also specifying the RemotePort as a string. Remove the quotes. The RemoteHost cannot be set like that. You need to use an IP address or DNS name. For example: "www.vbforums.com" would be fine. "http://vbforums.com" wouldn't. You would get the error "Valid name, no data record of requested type" in the Winsock_Error() event.
Al42
Jul 18th, 2007, 04:20 PM
i have code this 2 min ago and i want to ask if this code is right.
I try to make a client that opens a port and the server connect to this port.(reverse connection)Your terminology isn't correct.
The computer that initiates the connection request is called the client. The computer that receives the first connect request is called the server. what happens after that doesn't change things. If the computer that initiates the connection is a database server, it's a server on that level, but on the networking level it's the client.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.