simple client <-> proxy <-> server toy program
843789Mar 9 2010 — edited Mar 9 2010Hi.
I haven't done many cs courses yet, lately i am reading on some introduction to network programming, and i thought i should create a simple toy program to test a bit.
Essentially i'd like to keep the communication between client and server using bytes, so i'll but input/output streams. At the same time, i'd like to have the proxy and server and client hosted on the same pc. So, i'll be using local IP's like 127.xx.xx.xx
Client part:
1. open a socket to connect to proxy
2. get input and output streams
3. use loop to write random data to output stream, and read feedbacks from inputstream.
Proxy Part
1. opens a server soc to listen to client
2. opens a soc to connect to server
3. create 2 service objects to take care of IO, one for upstream(to server) and other for downstream
4. display and verify content.
Server Part:
1. open a server socket to listen to connections
2. create a service object to take care of stream IO
3. display IO streams to counter verify with client IO
Questions:
1. When constructing a socket for client side, i should be including proxy IP and proxy listened_port as parameters right?
if I try to put in a local ip such as 127.99.99.99, and port number 5999. At the same time i set my proxy port_to_listen_to as 5999
how will I know which address represents my proxy?
Will any random local IP work?
Will a thread be more appropriate since i am using threads in proxy and server?
2. My understanding of proxy is that it is partly a server, and partly a client. But i am not sure if i am right to create 2 threads to handle upstream and downstream operations independently. I have tried to stay out of global/static variable so that i can avoid synchronization part.
3. As for the server side. i have similar issues regarding the IP address problems mentioned above.
Can some one help me sort out my concepts?