Socket communication

R

ronnin.ubrasky

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
 
P

ppi

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
 
R

ronnin.ubrasky

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

jason.cipriani

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

Sam

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top