Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Monday, January 30, 2012

Unix Tools - Sockit , Python , C++ , Client , Server Programs Continue..

Previous >>

article by Vessna :
30-Jan-2012,Lab SD-416,by Dr.John Ham

>> Login to http://dekdee.buu.ac.th
>> Download kopy.py.txt and sockit2me-2.5.tar.xz (python code) from
http://127.0.0.1/~mrham by command : links http://127.0.0.1/~mrham
>> use arrow key for move and D bottom for download and Ctrl+C to exit browser
>> Change kopy.py.txt to kopy.py by command : mv kopy.py.txt kopy.py.txt
>> Change permission mode to run kopy.py by :
>> chmod +x kopy.py
or
>> chmod 0755 kopy.py
>> Run program kopy.py by command : ./kopy.py sockit2me-2.5.tar.xz newarchivetar
>> Then look at the new file newarchivetar and sockit2me-2.5.tar.xz are the same
size or not by command : ls -al
>> Check files by command : diff sockit2me-2.5.tar.xz newarchivetar
>> ( should not get output , which means files are the same and the copy work fine )
>> Extract file sockit2me-2.5.tar.zx by command : tar -xvJf sockit2me-2.5.tar.zx

>>> After extracted successful then go to directory sockit2me-2.5/ and See more the
video clip below from Video 2 up :

Video 1 :


Video 2 :


Video 3 :


Video 4 :


Video 5 :


Video 6 :






Video 1:

Sunday, January 29, 2012

Unix Tools - Sockit , Python , C , Client , Server Programs [Video]

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 >>>