Peter Kiers
asked on
How can i set a port number
Dear Experts,
In my programm I have put 2 edit-boxes, where the user must specify the IP-address/Hostname
and the Port number to make a connection to a server. The IP-address/Hostname editbox is finished. Only I have a hard time to find where in the procedure MakeConnect the port number
is specified!
I have put a partial code of the procedure MakeConnect, because it's a long procedure.
procedure MakeConnect;
var
usPort: u_short; <=============
...
usPort := pServAddr^.s_port; <===============
RemoteAddr.sin_family := AF_INET;
RemoteAddr.sin_addr.s_addr := ina.s_addr;
RemoteAddr.sin_port := usPort; <==============
psaddr := Pointer(@RemoteAddr);
The port 23 is specified in this code, because when i look at my logging i see this:
TCP Started.
Socket opened OK.
Foreign host name: 145.70.16.5
Address type: 2
Address length: 4
Foreign host address: 145.70.16.5
Local host name: cp557259-a
Address type: 2
Address length: 4
Local host address: 192.168.1.2
Bind successful
Remote Service Info.:
Name: telnet
Port: 23 <===========
Connect error: 10060
TCP Ended.
How can i when the user enter a port number in the edit-box pass it on to the
MakeConnect-procedure?
Greetings,
Peter Kiers
In my programm I have put 2 edit-boxes, where the user must specify the IP-address/Hostname
and the Port number to make a connection to a server. The IP-address/Hostname editbox is finished. Only I have a hard time to find where in the procedure MakeConnect the port number
is specified!
I have put a partial code of the procedure MakeConnect, because it's a long procedure.
procedure MakeConnect;
var
usPort: u_short; <=============
...
usPort := pServAddr^.s_port; <===============
RemoteAddr.sin_family := AF_INET;
RemoteAddr.sin_addr.s_addr
RemoteAddr.sin_port := usPort; <==============
psaddr := Pointer(@RemoteAddr);
The port 23 is specified in this code, because when i look at my logging i see this:
TCP Started.
Socket opened OK.
Foreign host name: 145.70.16.5
Address type: 2
Address length: 4
Foreign host address: 145.70.16.5
Local host name: cp557259-a
Address type: 2
Address length: 4
Local host address: 192.168.1.2
Bind successful
Remote Service Info.:
Name: telnet
Port: 23 <===========
Connect error: 10060
TCP Ended.
How can i when the user enter a port number in the edit-box pass it on to the
MakeConnect-procedure?
Greetings,
Peter Kiers
ASKER
Procedure MakeConnect;
I have put here al the lines with pServAddr:
var
pServAddr: PServEnt; <== is also declared
.....
pServAddr := getservbyname('telnet', 'tcp');
if pServAddr <> nil then
.....
usPort := pServAddr^.s_port;
RemoteAddr.sin_family := AF_INET;
RemoteAddr.sin_addr.s_addr := ina.s_addr;
RemoteAddr.sin_port := usPort;
.....
Peter
I have put here al the lines with pServAddr:
var
pServAddr: PServEnt; <== is also declared
.....
pServAddr := getservbyname('telnet', 'tcp');
if pServAddr <> nil then
.....
usPort := pServAddr^.s_port;
RemoteAddr.sin_family := AF_INET;
RemoteAddr.sin_addr.s_addr
RemoteAddr.sin_port := usPort;
.....
Peter
ASKER
I have put the complete procedure on my site
http://members.home.nl/peterkiers/
(click on the floppy-disk underneath the Under Construction bar)
I hope this makes it easer...
P.
http://members.home.nl/peterkiers/
(click on the floppy-disk underneath the Under Construction bar)
I hope this makes it easer...
P.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The portnumber that the user enters in a edit-box
is stored in a variable called ConnectPortName.
var
usPort: u_short;
...
usPort := //what do i have to put here???
RemoteAddr.sin_family := AF_INET;
RemoteAddr.sin_addr.s_addr := ina.s_addr;
RemoteAddr.sin_port := usPort;
psaddr := Pointer(@RemoteAddr);
end;
is stored in a variable called ConnectPortName.
var
usPort: u_short;
...
usPort := //what do i have to put here???
RemoteAddr.sin_family := AF_INET;
RemoteAddr.sin_addr.s_addr
RemoteAddr.sin_port := usPort;
psaddr := Pointer(@RemoteAddr);
end;
ASKER
Thanks i have got it.
Peter Kiers
Peter Kiers
what is pServAddr and where is it filled in?