CSocket::Create() returns 0

I've connecting other process with socket connecting. So I create client socket which is object of CSocket Class. And I call Create method in CSocket class and I make my own program. But It doesn't work in create. It returns 0 value. Please tell me why does this happens.

Here's my brief code

CSocket *socket = new CSocket();
if(socket->Create())
   if(socket->Connect("127.0.0.1",0))
     socket->Send(widthCap, sizeof(widthCap));
socket->Close();

Thank you

Answers


Call GetLastError() and look the value up here. I would guess that you have a firewall that blocks your exe. Remember that adding your exe to your firewall exception list will not help as you probably build a new exe every time you hit F5.


Need Your Help

How does Ctrl-C terminate a child process?

bash shell process sh

I am trying to understand how Ctrl-C terminates a child but not a parent process. I see this behavior in some script shells like bash where you can start some long-running process and then terminat...

jQuery event help - I have a Select list with OptGroups, I want to call function only if option belongs to a certain optgroup

javascript jquery html ajax

I have a select list with optgroups. I want to add a handler for the drop down selected index change, how do I tell which optgroup the selected item belongs to? This determines further execution pa...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.