Socket communication

Discussion in 'C++' started by ronnin.ubrasky@gmail.com, Feb 19, 2008.

  1. Guest

    Hi all,
    I am having two programs that should communicate using sockets.
    Program A [has some import data on port 2121] it sends some bytes to
    ProgramB.
    The programB then process them and send back to A[on port 1234.

    The problem is that,when I start program A it gives an error that it
    cannot connect to port 2121.
    But then if start programB it says that it cannot connect to port
    1234..

    How can I solve this issue
     
    , Feb 19, 2008
    #1
    1. Advertising

  2. ppi Guest

    On Feb 19, 6:24 pm, wrote:
    > Hi all,
    > I am having two programs that should communicate using sockets.
    > Program A [has some import data on port 2121] it sends some bytes to
    > ProgramB.
    > The programB then process them and send back to A[on port 1234.
    >
    > The problem is that,when I start program A it gives an error that it
    > cannot connect to port 2121.
    > But then if start programB it says that it cannot connect to port
    > 1234..
    >
    > How can I solve this issue


    Sockets are not part of the c++ language, what API/library are u
    using ?
    if you are using plain BSD/POSIX sockets, you should ask in
    comp.unix.programmer.
    what sockets are you using, UDP, TCP, UNIX ?
    Attach some code ...

    cheers,
    paulo
     
    ppi, Feb 19, 2008
    #2
    1. Advertising

  3. Guest

    Hi Paulo,
    These are 2 tcp sockets.

    I think that whole issue is the server and client problem.
    programA expects a server to accept clients on 2121 and programb
    expects a server on 1234.

    But I cannot start neither one at first because program A is dependent
    on program B and program B is dependent on A.

    How can I solve this.I am sure that there is way around this.
     
    , Feb 20, 2008
    #3
  4. Guest

    <> wrote in message news:8a1c7448-
    ...
    > [snip]
    > But I cannot start neither one at first because program A is dependent
    > on program B and program B is dependent on A.
    >
    > How can I solve this.I am sure that there is way around this.


    Why are you doing it this way? Consider just having Program A listen
    on a single port, and have Program B connect to that port when it
    starts. Sockets can be used for two-way communications. There is
    normally no reason to have two separate connections. If you also want
    the option to make Program B start without Program A already running,
    that's just a matter of designing your UI differently... instead of
    making Program B fail to start if it can't connect, make it auto retry
    in the background, or add a button allowing the user to choose when to
    connect, or something.

    This newsgroup is more for specific questions about syntax and
    semantics of the C++ language, it's not a network programming
    newsgroup, and it's not for algorithms or UI design either. You may
    not get the results you are expecting here.

    Jason
     
    , Feb 20, 2008
    #4
  5. Sam Guest

    writes:

    > Hi Paulo,
    > These are 2 tcp sockets.
    >
    > I think that whole issue is the server and client problem.
    > programA expects a server to accept clients on 2121 and programb
    > expects a server on 1234.
    >
    > But I cannot start neither one at first because program A is dependent
    > on program B and program B is dependent on A.
    >
    > How can I solve this.I am sure that there is way around this.


    Yes, there is. However:

    1) This has nothing to do with the C++ language, and

    2) The correct answer depends on factors that you have not provided, such as
    which program gets started first; who is the first one to initiate the
    connection; and several other factors that are unique to your situation.
    There is no generic one-size-fits-all answer anyone can give you.

    Item #2 does not mean that you'll get your answer on this newsgroup, see
    item #1. Notwithstanding which newsgroup you will choose to follow up to,
    the people who are likely to know the answer to your question are the same
    people who are likely to figure out that you're either trying to get someone
    to do your own homework assignment, or your daytime job. This seems to be
    the likely situation, given that your IP address is sah205.atp.nicta.com.au
    and what I see on http://nicta.com.au.

    So, don't even bother.


    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.7 (GNU/Linux)

    iD8DBQBHu3hwx9p3GYHlUOIRAi9MAJ9AX2nPOo1Wpq42hgdnf/9EEivzpwCfW8qS
    ugWR4ZPGoyR6gL2t2kExDBM=
    =G7JA
    -----END PGP SIGNATURE-----
     
    Sam, Feb 20, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Nagy
    Replies:
    1
    Views:
    4,875
    Mark Wooding
    Jan 27, 2009
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    980
    Jean-Paul Calderone
    Jan 27, 2009
  3. Laszlo Nagy
    Replies:
    0
    Views:
    558
    Laszlo Nagy
    Feb 1, 2009
  4. Steve Holden
    Replies:
    0
    Views:
    674
    Steve Holden
    Feb 1, 2009
  5. Steve Holden
    Replies:
    1
    Views:
    727
Loading...

Share This Page