Listening and Connecting At The Same Port

I use MFC Visual C++ 4.2.

I have developed a network application using CSocket. 

I am having 3 applications:
Server app, Client app, Broadcaster app. 

If Server app has error and needs to be restarted, Broadcaster was meant to 
be a TEMPORARY Server. And EACH TIME the Server app restarted, it will act  
as CLIENT and connect to the Broadcaster then the Server app will return to 
its ORIGINAL role as Server then Broadcaster app will do 
BroadcastSystemMessage( "WAKE UP" ) to Client application notifying that the 
Server is ready to receive Join request. 

1. I did all this and during DEBUGGING time, I have all process ran 
correctly and all message from Server to Client, Broadcast System Message 
also OK. But when I just run all application, nothing's happened. 

2. I did all this on the same port of 2000. Does the same port used for 
Sending and Receiving will not work? 

Thank you very much.
0
Chris6982 (632)
12/23/2008 5:03:01 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
1116 Views

Similar Articles

[PageSpeed] 38

Are you running all the applications on the same machine?

Is there more than one application listening on the same port on the same 
machine? (this is the only restriction.  If there is already an socket 
listening on port x then when you try to create another one that listens to 
the same port it will fail).

Try putting some logfile outputs or messageboxs in your application to find 
out where and why it fails.

AliR.

"Chris" <Chris@discussions.microsoft.com> wrote in message 
news:33598BF5-E291-4914-9BCB-8A70A1E467D1@microsoft.com...
>I use MFC Visual C++ 4.2.
>
> I have developed a network application using CSocket.
>
> I am having 3 applications:
> Server app, Client app, Broadcaster app.
>
> If Server app has error and needs to be restarted, Broadcaster was meant 
> to
> be a TEMPORARY Server. And EACH TIME the Server app restarted, it will act
> as CLIENT and connect to the Broadcaster then the Server app will return 
> to
> its ORIGINAL role as Server then Broadcaster app will do
> BroadcastSystemMessage( "WAKE UP" ) to Client application notifying that 
> the
> Server is ready to receive Join request.
>
> 1. I did all this and during DEBUGGING time, I have all process ran
> correctly and all message from Server to Client, Broadcast System Message
> also OK. But when I just run all application, nothing's happened.
>
> 2. I did all this on the same port of 2000. Does the same port used for
> Sending and Receiving will not work?
>
> Thank you very much. 


0
AliR3470 (3234)
12/23/2008 4:00:11 PM
See below....
On Mon, 22 Dec 2008 21:03:01 -0800, Chris <Chris@discussions.microsoft.com> wrote:

>I use MFC Visual C++ 4.2.
>
>I have developed a network application using CSocket. 
****
CSocket is usually a very bad choice for robust network code.  In particular, there were
significant bugs in the 4.2 implementation of CSocket that were not in CAsyncSocket.
****
>
>I am having 3 applications:
>Server app, Client app, Broadcaster app. 
>
>If Server app has error and needs to be restarted, Broadcaster was meant to 
>be a TEMPORARY Server. And EACH TIME the Server app restarted, it will act  
>as CLIENT and connect to the Broadcaster then the Server app will return to 
>its ORIGINAL role as Server then Broadcaster app will do 
>BroadcastSystemMessage( "WAKE UP" ) to Client application notifying that the 
>Server is ready to receive Join request. 
*****
How does the broadcaster know it should become a server?  Note that only one process can
own an <IP, Port> pair at a time.  This would require that the broadcaster app detect when
the server fails, and it would then bind the <IP, Port> pair to it, and when it detects
the server is back up, it has to ask the broadcaster to release the <IP, port> pair and
then the server has to rebind it, which seems a bit complex to get right.
****
>
>1. I did all this and during DEBUGGING time, I have all process ran 
>correctly and all message from Server to Client, Broadcast System Message 
>also OK. But when I just run all application, nothing's happened. 
*****
Nothing happens?  What's 'nothing' compared to what is expected to happen.?  If all
processes are running 'correctly', then they should be doing whatever they are supposed to
be doing, so they aren't running 'correctly', but what is happening or not happening?
****
>
>2. I did all this on the same port of 2000. Does the same port used for 
>Sending and Receiving will not work? 
****
That is correct.  One process can own own port.  You cannot use it for two purposes, or in
two processes.
			joe
****
>
>Thank you very much.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15977)
12/23/2008 6:51:50 PM
Reply:

Similar Artilces:

Listen to me
SEXY 24-Hrs +91 9810577227 ...

Remote Desktop connection between 2 vista.
hello Im connecting with remote desktop from one pc to another using win vista using the administrator account. When the login establish, the other machine logging out. is there any way to stay online the remote so the monitor stay active? thanks On Mon, 1 Feb 2010 05:05:01 -0800, bill <bill@discussions.microsoft.com> wrote: >hello > >Im connecting with remote desktop from one pc to another using win vista >using the administrator account. When the login establish, the other machine >logging out. is there any way to stay online the remote so the mon...

Casyncsocket::Connect behavior different in release build
I've a routine that creates a sock_stream (tcp) socket, connects, and communicates that uses mfc casyncsocket class. I've been using it in debug mode build for a couple years. After the connect() call, if the return is 0 it checks if GetLastError is WSAEWOULDBLOCK, and if it is awaits an OnConnect callback. It's always worked pretty much "exactly" as the CAsyncSocket::Connect call describes. I switched to release build just a few days ago, and have been fixing various things that worked forgivingly in debug build (mostly initialization issues). The really curious thi...

How do we connect Crystal Reports through a VPN?
How do we connect Crystal Reports through a VPN and connect to the SSO connection to the CRM databases? I see the SSO when I am logged on locally but not when I am connected via VPN. Thanks in advance for your assistance. -- JDM A+ MCP Certified are you trying to run crystal report designer over vpn? -- John O'Donnell Microsoft CRM MVP http://www.mscrmfaq.us "JD" <JD@discussions.microsoft.com> wrote in message news:0FD9688E-BECD-4393-8812-C77D13DCD671@microsoft.com... > How do we connect Crystal Reports through a VPN and connect to the SSO > connection to ...

Trace Listeners
Hi. How can I dynamically decide which trace listener to use? I tried to use trace switches but it seems that I can't do that with switches. Suppose the configuration file below: <system.diagnostics> <trace autoflush="true"> <listeners> <add name="toFile" type="TextWriterTraceListener" initializeData="App.log" /> <add name="toEvent" type="EventLogTraceListener" initializeData="AppLog" /> </listeners> </trace> </system.diagnostics> Is it p...

connecting to a new machine
Hi- I added another machine to my network .. I tried to connect to my database via admin. with connect and the server name did not show up on the list (file, connect, server)... So it is not recognizing the Server... Why I wonder? Brent type in the server name. "Brent" <sagemaster@mvdsl.com> wrote in message news:uhHjMZsWHHA.1180@TK2MSFTNGP05.phx.gbl... > Hi- I added another machine to my network .. I tried to connect to my > database via admin. with connect and the server name did not show up on > the list (file, connect, server)... So it is not reco...

Unable to connect to the microsoft exchange server
Hey Guys, i'm using Microsoft outlook 2003, when i try to connect it to my exchange server i get error message " The connection to the microsoft exchange server is unavailable. outlook must be online or connectedd to complete this action" it was working fine till last week, i formated my laptop & configured outlook with the same old settings. but still m gettin this pop up when ever i try to login. Can u guys help me out this... ...

Money 2005 Internet Connection
I recently purchased a new computer with Money 2005 preinstalled. I uploaed my old Money 2000 file fine but the converted file will not connect to the internet through Money and I cannot update quotes,etc. on line. Anyone else have this problem? Suggestions. In microsoft.public.money, Pags wrote: >I recently purchased a new computer with Money 2005 preinstalled. I uploaed >my old Money 2000 file fine but the converted file will not connect to the >internet through Money and I cannot update quotes,etc. on line. Anyone else >have this problem? Suggestions. Let Money 2005 cre...

Network Connection Error
Gents, I am running into Network Connection Error when trying to process a credit card. It is a visa, I know my merchant is setup for VISA, along with every other card you could think of. Is there any specific setting that I should concentrate on? Since the error is so vague. I have the gateways typed in correctly, I have my Firewalls turned off. Any suggestions ? Thanks again fellas, Sam We get this error everyday, I dont know what the cause is, but a restart of all the stations including the DB server always fixes it. "Sam Marinelli" wrote: > Gents, > I am running...

Connecting to MySQL at Startup
Hello, I've installed the ODBC connector for MySQL and can go into Access and manually link to the MySQL tables. Everything works fine this way. But rather than go into the Windows Data Source Adminstrator on each user's computer, how would you code an MS Access front end to connect to MySQL tables at startup? Where would you put the code and how would you call it when the Access database is opened? Thanks for your help! It will be assumed that your database gets installed on each pc. I explain why here: http://www.members.shaw.ca/AlbertKallal/Articles/split/index.htm Then, you...

Can not connect to
After installing office XP sp3 today, I am unable to send/receive e-mail using Outlook 2002. I am able to send and receive e-mail using my version of Outlook Express (ver 6). When I run a test of my e-mail account in Outlook 2002 I get the following results: Establish network connection OK Find outgoing mail server (SMTP) OK Find incoming POP3 FAILED What can I do to resolve this problem? Any help would be greatly appreciated. Thank you, Thomas J. Kroljic Thomas Kroljic <tkroljic@covad.n...

how could i know which port is being listened?
how could i know which port is listened by a specific appz ? or is there any function could tell me how many ports are currently being using and what are they? i am new to winsock Hi David, Refer the iana site to get the list of well known ports http://www.iana.org/assignments/port-numbers Vijay "David" <David@discussions.microsoft.com> wrote in message news:5BDF1CE0-4637-47F8-AC37-30B73331855B@microsoft.com... > how could i know which port is listened by a specific appz ? or is there > any > function could tell me how many ports are currently being using and wh...

CAsyncSocket connection status
Is there any way I can check if the connection is established or not (e.g. using the m_hSocket to check, instead of those OnConnect or OnClose events)? Thanks! ...

RE: Can't connect to OWA
Lee Derbyshire [MVP] wrote: > 404 means 'page not found'. Have a look in IIS Manager on the OWA > server, and make sure that it still has a Virtual Directory named > 'Exchange'. > > Lee. > > Yes, IIS has still a Virtual Directory named "Exchange". When I try to connect via IE to the OWA from the OWA Server I see the logon form, but after having provided any username and password (or domain\username and password) I receive the HTTP 404 error. ...

Business Port Dll
I have successfully installed Business Portal 2.5. During purchase requisition test, I got an error. "Input string is not in correct format" or "Purchase Order Failure - Error in the application" In order to fix this error I need fixed Microsoft.dynamics.purchaseorder.services.dll. which is not available for downloading (KB908171). If someone has the hotfix and the dll kindly email to me. rajesh_anandan@hotmail.com. Thanks in Advance. ...

Leader Lines Connecting Chart to Box
I have a pie chart with a text box (to the upper right). I take one slice and draw lines from the top and bottom of the outside ends of the slice to connect to the text box. Naturally, as the data changes, the slice changes (or the pie slightly rotates) which requires me to adjust the lines to the box. Is there a way to have these lines track with the chart? Hi, Here is a possible solution. It uses a combination chart which allows the lines to be plotted and updated dynamically by using a xy-scatter. http://www.andypope.info/charts/customerleaderlines.htm If you have to still with ...

Unable to connect to online quote server... AGAIN!
I can't get quotes again this morning. Anybody else? Just opened Money...same here. Only happens when the markets up. <g.m.cox.mail@gmail.com> wrote in message news:fbe1ee53-01df-4e30-88b4-58c8c1146c33@w35g2000yqm.googlegroups.com... >I can't get quotes again this morning. Anybody else? I also have been having trouble connecting!! <g.m.cox.mail@gmail.com> wrote in message news:fbe1ee53-01df-4e30-88b4-58c8c1146c33@w35g2000yqm.googlegroups.com... >I can't get quotes again this morning. Anybody else? What version of Money? Or is this directly on the MSN ...

Connecting to Sql Server
I have been using Named Pipes to connect to our SQL server for almost a year now. Sporadically, connection to the database is dropped, I have checked cabling, UPS, switch, disconnected every piece of POS hardware it is still will occur every great once in a while. It usually occurs when trying to get the date and time, however I have seen it happen immediatedly after scanning an item too, and a slightly differerent error occurs. Mainly I wonder if changing to a TCP/IP connection would help. I have been unable to get a connection to form between the server and a client this way. T...

web port error
We have GP, BP, SSRS, Forecaster, and Webport all installed on one server. GP, BP, and Forecaster all work. SSRS and WEbport get the same error when trying to access them through IE. Server Error in '/xxxx' Application Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration appropriately. Parser Error Message: Could not load file or assembly 'Microsoft.BusinessFramework' or one of its dependencies. The system cannot ...

Exchange Connection Filtering Problem
I'm currently setting up exchange filtering so that mail can only be received directly from our mail filtering service "messagelabs". The request is to accept connections form a designated range of IP addresses - no problem, then to deny from everything else i.e. 0.0.0.0 with a subnet mask of 0.0.0.0. On entering the deny range of 0.0.0.0 I cannot add it as the 'ok' button stays greyed out. Messagelabs have seen no issue with this with other clients - is there anything that I'm missing or doing wrong? I'm running exchange server 2003 SP1 on SBS 2003. The info...

Connection strings on linked tables do not refresh properly!!
We use SQL Server 2k as the database and MS Access 2k as the client.We have two versions of the client, Training and production.Because each user's permissions are different we refresh the links tothe database with the following code:(rs contains a list of tables to be relinked)ConnectString = "ODBC;DRIVER={SQLSERVER};SERVER=myserver;DATABASE=Training;UID=" & Usr & ";PWD=" & Pwd& ";"Set db = CurrentDbrs.MoveFirstDo While Not rs.EOF Debug.Print rs(0) Set td = db.TableDefs(rs(0)) With td .Connect = ODBC_STR .RefreshLink End ...

XML Pipeline
Hi. We were apprached by our supplier to update our inventory using their xml output. The question I have is how (brief overview) would this work and what are the security concerns. Our system was design in .net with a sql 2000 back-end. I understand that this is a fairly basic question for this group, but I'd thought that I'd ask here and recieve expert insight. Thank you in advance for your assistance. JJ ...

MFC Socket listener
Hello everyone, got a quick question here that hopefully someone can help me with. Basically I am having trouble with my Client application which uses MFC CSockets. I currently can only listen to one port (say 4000), and I need to be able to listen to multiple ports. Originally I just set up two listeners (one listening on 4000 another on 4200) but the problem with this is that I need to know which Listener is flagged when I call the OnAccept() method (actually this method is calling another function OnProcessPendingAccept() at which point I need to know which listener got tagged). Basical...

Unable to set listening port on an activeX control
Hi. I have incorporated an activeX control on my application but when i set its listening port to a particular port it does not get set. When i do a netstat -ab on the command line, the port that my application listens to is some random port other than what i have set. What could be the problem? And how do i get it right? The similar application works in VB. Regards Rahul "rahulthathoo" <rahul.thathoo@gmail.com> schrieb im Newsbeitrag news:1153130542.084178.205340@b28g2000cwb.googlegroups.com... > Hi. > I have incorporated an activeX control on my application but when...

CAsyncSocket connect problem #2
Okay, Here is my network setup: My pc NIC IP is 10.128.98.121 My remote pc IP is 10.128.98.100 Now I wrote the CAsyncSocket class that will call Connect("10.128.98.100", 1234). By right, it should return error trying to establish connection to the remote pc which is on the same network (as I can PING it) but the function returns me 0 which means it fails. Why is that? Am I missing something? Mike cybernerdsx2 wrote: > Okay, > > Here is my network setup: > > > My pc NIC IP is 10.128.98.121 > My remote pc IP is 10.128.98.100 > > > Now I wr...