Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


C++ Networked BlackJack Card Game

Posted on 2011-04-28
Medium Priority
Last Modified: 2012-06-21
Dear Experts,

I have been developing a C++ game over the last few days with your assistance.

I need your help in one final little instance, I am attempting to get the game to connect to another client as a server, but it fails to connect - very strange. I have been racking my brains over this all last night, and cannot find the answer.

I have included a Mediafire locker, with the p-a-ssw-o-rd protected content as this is proprietary code.

Please note these are RAR files, and the p-assw-ord is shown within the image attached. If you could please take a look at my application, and see if there is anything wrong with it, I would be extremely grateful.

If you can see any other errors, please discuss them - but please be careful about discussing individual code.

Code Share Folder: http://www.mediafire.com/?9q9dz4ib0xk25

Kind Regards,

As described
Question by:SME_Paddington
  • 4
  • 3
LVL 35

Accepted Solution

sarabande earned 2000 total points
ID: 35482514
can you tell what errors you get when connecting to another client?

what is the value you get when calling WSAGetLastError() ?

did you get the output "Exiting because Connect failed" from CSimpleClient_TCP::Connect ?

did you ever achieved to connect to an other client/server?


Author Comment

ID: 35482642
Hi Sara,

I have not checked yet WSAGetLastError().

Yes, from CSimpleClient_TCP:Connect... I received that exact error.

 I am able to have a client connect to the server console, but I am not able to initiate a remote connection to the other server.


 Client -> Server    = Working Perfectly
 Server <- Client    = Attempting to connect failed. I normally receive the error: Bind() failed.

After having edited the code, it now times out. I appreciate you taking time to look at my code.

There is also one last file for the CSimpleClient_TCP which I was not able to initialise (that is included in the original built file). I will upload that to the media share, same p4ss-w0rd as before. It could be the source of the problem.

Kind Regards
LVL 35

Expert Comment

ID: 35483081
for remote connection you need your firewall to allow that. did you use windows firewall or firewall from antivirus (or both???)  ?

the settings of your firewall should allow you to open output connections for some ports.

how do you address the remote server? by name or by ip? if ip address, is it ip4 or ip6?

if by name, are you able to ping at the commandline using that name? if not you should either add the name - ip relation to hosts file (on xp it is at system32\drivers\etc) or change the server name to ip address in your client.

unfortunately there are many reasons why a socket connection to a remote server could fail. can you call the WSAGetLastError() and check in winerror.h what the return value means?


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 35485148
I have been using port: 8015, and essentially this is not blocked by either firewall. (I have not tried turning off the firewall yet).

I was connecting to a remote computer on my network, which is connected locally via the use of Wireless. When not connected via via wireless it would not allow the connection, as it was blocked by 2 routers that exist on the network in between the 2 nodes.

Situation 1 (Wired Cable) :
MyComp ==> Router 1 (I.net Access) ==> Router 2 ==> Remote PC

RemotePC fails to connect to MyComp.

Situation 2 (Wireless):
MyComp ==> Router 1 (I.net Access) ~~~~> RemotePC

MyComp fails to connect to RemotePC

Remote Connection performed by IP. IPV4.

Okay Sara, will do as soon as I have written up the report for this coding I will check out the WSAGetLastError() message. Please bear with me, as I am submitting this tonight. As soon as the report is done, I will update you on the status of the errors.

Author Comment

ID: 35485168
You may be right, looking at it now, if remote connections to the local IP are blocked, then it could essentially stop communication from occurring whereas remote connections from the local IP are not blocked...

Situation 1 and Situation 2 have not been fully tested with all states please note.
LVL 35

Assisted Solution

sarabande earned 2000 total points
ID: 35485240
by the way, you wouldn't bind a socket at the client side when connecting to a server. the bind was made by the server only. so you shouldn't get a bind error beside you would use the same port (number) for receive (where your clients listens for other clients to connect) socket  and send socket (the one which fails).


Author Closing Comment

ID: 35490044
Debugging with this function found the error.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question