by 23-Jan-2012
recorded by Vessna
This is where the original code for the C programs in the sockit2me examples comes from. I had to update it a little bit, but the socket information discussed on this web page is still mostly correct. However, modern linux systems do not have the h_addr macro definition any more, so I had to adjust the code for that. Also, atoi() is not safe, so I had to replace that.
Video :
Lecture :
1. Download socket2me-2.0.tar.xz from dekdee.buu.ac.th/~mrham >> by links
command >> links http://dekdee.buu.ac.th/~mrham
>> then choose file socket2me-2.0.tar.xz >> ok
2. Extract it by tar >> tar xvJf sockit2me-2.0.tar.xz ( xvJf >> .xz )
go to directory sockit2me-2.0/
comand >> make to complie program
3. There are import file
in C language >>
client with server
in phyton language >>
client.py with server.py
4. How to send a message to server
* open in 2 windows , one for client and other for server
* to set name remcommand :
command >> export PS1="myserver $" on server windows
command >> export PS1="myclient $" on client windows
* sending message from client to sever
in C program :
myserver$
command >> ./server 10008 10008 is port number
[waiting for client]
myclient$
command >> ./client localhost 10008
Type your message : Hello server I am client 10008
I got your message
myserver$
Hello server I am client 10008
mysever$
in Phyton program :
myserver$
command >> ./server.py 10008
[waiting for client]
myclient$
command >> ./client localhost 10008
Type your messgae : Hello server I am client.py 10008
I got your message
myserver$
Hello sever I am client.py 10008
myserver$
5. Look at source code the program
phyton >> client.py & server.py
C >> client.c & server.c
Download :
sockit2me-2.0.tar.xz
This archive contains simple client and server examples for TCP/IP stream sockets in C99 and python3.
Next >>>
No comments:
Post a Comment