Peer to Peer Tcp

This is a discussion on Peer to Peer Tcp within the Networking/Device Communication forums, part of the General Programming Boards category; In programs using TCP we usually have a separate client and server. Is it possible to have a program using ...

  1. #1
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    489

    Peer to Peer Tcp

    In programs using TCP we usually have a separate client and server.
    Is it possible to have a program using TCP connection to act both as
    server and as client?
    Please help.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,338
    Yes, that is possible.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    489

    Thanks

    Thank you Salem .Can u tell me how please?. Is there any special functions to do it?.
    I encounter the following problem of a graph.

    A-------B---------C

    where A,B,C are nodes where B must act as client to A but server to C.
    Please help me as i am new to C & Socket programming.
    Thanks in advance.
    Last edited by stevesmithx; 09-24-2007 at 06:19 AM.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,338
    So in other words, A and C would normally communicate directly, but B is there to act as a proxy or a filter.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    489
    yes like a filter.Can one program(B) listen and connect on two different sockets?

  6. #6
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630
    Yes.

  7. #7
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    489
    hi guys,
    Can u please give me some idea about how to solve this with specific functions?

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by stevesmithx View Post
    hi guys,
    Can u please give me some idea about how to solve this with specific functions?
    If you know what functions you need for either end of the communication, you probably would need the same functions for doing a "filter" or "proxy" server.

    If you don't know/understand how to do that, then you probably need to read up a bit on "programming sockets".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    489
    All right.Thanks for the help guys.

  10. #10
    Registered User
    Join Date
    Oct 2007
    Posts
    1
    wrt socket programming :

    Local addressing format is used by sockets that are local to your hosts.
    eg : lpr command uses local socket to communicate with spooling service.

    It is possible to use TCP / IP for local communication, but not recommended ( less efficient )

    To communicate betwn nodes : TCP / IP (AF_INET)
    TO communicate with local sockets : Local addressing format ( AF_UNIX)

    Following show communication betwn
    A to B
    betwn B and B
    B to C


    A ---- (IPv4) ---- B ----- (local addressing format) -----B ----- (IPv4) ----- C

    HTH

    Thanks,
    Rohit Kalsarpe

  11. #11
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189

    Actual help

    I would apologize for the tards on this board, but if I did that Id never have time to post anything useful.

    Since you didnt mention information that I woudl need to provide a helpful answer, like what OS (windows or linux) you are using I will go ahead and assume you are programmign for windows.

    The API function you want to use are the following

    WSAStartup()
    socket()
    bind()
    connect()
    listen()
    send()
    recv()


    WSACleanup()

    those will let you make a basic functional tcp connection, from there you can look into the more complex issues fo blocking versus non-blocking, protocol types etc.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. TCP Header problem (error)
    By nasim751 in forum C Programming
    Replies: 1
    Last Post: 04-25-2008, 07:30 AM
  2. Accessing TCP flags in TCP packets on Linux using C !!
    By vishamr in forum Linux Programming
    Replies: 2
    Last Post: 10-16-2006, 08:48 AM
  3. SSH Hacker Activity!! AAHHH!!
    By Kleid-0 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 03-06-2005, 02:53 PM
  4. OOP for DirectPlay Peer to Peer program
    By curlious in forum Networking/Device Communication
    Replies: 0
    Last Post: 11-03-2003, 11:21 PM
  5. TCP TIME_WAIT state
    By Engineer in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 12-27-2001, 07:50 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21