Graphics Programs Reference
In-Depth Information
When compiled and run, the program binds to port 7890 of the host and
waits for incoming connections:
reader@hacking:~/booksrc $ gcc simple_server.c
reader@hacking:~/booksrc $ ./a.out
A telnet client basically works like a generic TCP connection client, so it
can be used to connect to the simple server by specifying the target IP address
and port.
From a Remote Machine
matrix@euclid:~ $ telnet 192.168.42.248 7890
Trying 192.168.42.248...
Connected to 192.168.42.248.
Escape character is '^]'.
Hello, world!
this is a test
f jsghau;ehg;ihskjfhasdkfjhaskjvhfdkjhvbkjgf
Upon connection, the server sends the string Hello, world! , and the rest
is the local character echo of me typing this is a test and a line of keyboard
mashing. Since telnet is line-buffered, each of these two lines is sent back to the
server when ENTER is pressed. Back on the server side, the output shows the
connection and the packets of data that are sent back.
On a Local Machine
reader@hacking:~/booksrc $ ./a.out
server: got connection from 192.168.42.1 port 56971
RECV: 16 bytes
74 68 69 73 20 69 73 20 61 20 74 65 73 74 0d 0a | This is a test...
RECV: 45 bytes
66 6a 73 67 68 61 75 3b 65 68 67 3b 69 68 73 6b | fjsghau;ehg;ihsk
6a 66 68 61 73 64 6b 66 6a 68 61 73 6b 6a 76 68 | jfhasdkfjhaskjvh
66 64 6b 6a 68 76 62 6b 6a 67 66 0d 0a | fdkjhvbkjgf...
0x426
A Web Client Example
The telnet program works well as a client for our server, so there really isn't
much reason to write a specialized client. However, there are thousands of
different types of servers that accept standard TCP/IP connections. Every
time you use a web browser, it makes a connection to a webserver somewhere.
This connection transmits the web page over the connection using HTTP,
which defines a certain way to request and send information. By default,
webservers run on port 80, which is listed along with many other default
ports in /etc/services.
Search WWH ::




Custom Search