Click here to Skip to main content
15,898,371 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Unresolved external symbol Pin
Pryabu3-Jun-09 1:11
Pryabu3-Jun-09 1:11 
AnswerRe: Unresolved external symbol Pin
Code-o-mat2-Jun-09 21:52
Code-o-mat2-Jun-09 21:52 
JokeRe: Unresolved external symbol Pin
CPallini2-Jun-09 22:03
mveCPallini2-Jun-09 22:03 
GeneralRe: Unresolved external symbol Pin
Code-o-mat2-Jun-09 22:09
Code-o-mat2-Jun-09 22:09 
QuestionPlease help me regarding LoadCursor and SetCursor Pin
ptr_Electron2-Jun-09 21:18
ptr_Electron2-Jun-09 21:18 
Question3D border for Edit control Pin
Benjamin Bruno2-Jun-09 19:30
Benjamin Bruno2-Jun-09 19:30 
AnswerRe: 3D border for Edit control Pin
Naveen2-Jun-09 20:18
Naveen2-Jun-09 20:18 
Questionquestion regarding sockets Pin
mkrtchyanmarianna2-Jun-09 19:12
mkrtchyanmarianna2-Jun-09 19:12 
I have a question regarding sockets. I am trying to write two programs that will establish connection between each other to send and receive massages. One program sets connection the code is the following:
struct in_addr convaddr;
BOOL flag=TRUE;
while (flag)
{
s= socket(AF_INET,SOCK_STREAM,0);
if (s == INVALID_SOCKET)
flag=TRUE;
else
flag=FALSE;
}
addr.sin_family = AF_INET;
addr.sin_port = htons(1026);
if (onemach)
addr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
else
{
m_ServerIP=getIP();
convaddr.s_addr=atoi(m_ServerIP);
mip=inet_ntoa(convaddr);
addr.sin_addr.S_un.S_addr = inet_addr(mip);
}
flag=TRUE;
while (flag)
{
if (connect(s, (struct sockaddr *)&addr, sizeof(struct sockaddr))==0)
{
flag=FALSE;
}
else
{
Sleep(500);
}
}
And the other accepts connection:
while (flag)
{
sock= socket(AF_INET,SOCK_STREAM,0);
if (sock == INVALID_SOCKET)
flag=TRUE;
else
flag=FALSE;
}
sin.sin_family = AF_INET;
sin.sin_port = htons(1026);
sin.sin_addr.s_addr = INADDR_ANY;

int err=-1;
while (err==-1)
err=bind( sock, (LPSOCKADDR)&sin, sizeof(sin) );
err=-1;
while (err!=0)
err = listen( sock, SOMAXCONN); //SOMAXCONN defined as 5

SOCKET Recv;
SOCKADDR_IN from;

int fromlen=sizeof(from);
//gets the address and port of remote/distant comp.
Recv=accept(sock,(struct sockaddr*)&from, &fromlen);//waits for not defined time

hostIP=new char [37];
hostIP=inet_ntoa(from.sin_addr);
hostPort=htons(from.sin_port);

the problem is that sometimes it works correct: establishes connection and interchanges the massages and sometimes it can’t establish the connection, even if it gets right ip addresses. I will appreciate it greatly if anyone can help me to find where the error comes or to improve the code. Thanks in advance.
AnswerRe: question regarding sockets Pin
Stuart Dootson2-Jun-09 22:06
professionalStuart Dootson2-Jun-09 22:06 
QuestionHow to free unsigned long pointer variable? Pin
VCProgrammer2-Jun-09 19:05
VCProgrammer2-Jun-09 19:05 
AnswerRe: How to free unsigned long pointer variable? Pin
Naveen2-Jun-09 20:03
Naveen2-Jun-09 20:03 
QuestionWindow maximize and Minimize Pin
002comp2-Jun-09 18:45
002comp2-Jun-09 18:45 
AnswerRe: Window maximize and Minimize Pin
Naveen2-Jun-09 18:56
Naveen2-Jun-09 18:56 
GeneralRe: Window maximize and Minimize Pin
002comp2-Jun-09 19:06
002comp2-Jun-09 19:06 
GeneralRe: Window maximize and Minimize Pin
Naveen2-Jun-09 19:11
Naveen2-Jun-09 19:11 
GeneralRe: Window maximize and Minimize Pin
002comp2-Jun-09 20:36
002comp2-Jun-09 20:36 
GeneralRe: Window maximize and Minimize Pin
Naveen2-Jun-09 20:48
Naveen2-Jun-09 20:48 
GeneralRe: Window maximize and Minimize Pin
002comp2-Jun-09 21:21
002comp2-Jun-09 21:21 
GeneralRe: Window maximize and Minimize Pin
002comp2-Jun-09 22:48
002comp2-Jun-09 22:48 
QuestionCDockablePane without Close button PinPopular
VCsamir2-Jun-09 18:23
VCsamir2-Jun-09 18:23 
AnswerRe: CDockablePane without Close button Pin
laiboy6-Feb-10 1:41
laiboy6-Feb-10 1:41 
GeneralRe: CDockablePane without Close button Pin
Alexandre GRANVAUD16-May-11 23:09
Alexandre GRANVAUD16-May-11 23:09 
QuestionHow to design a decoder in C++? Pin
kapardhi2-Jun-09 18:04
kapardhi2-Jun-09 18:04 
AnswerRe: How to design a decoder in C++? Pin
CPallini2-Jun-09 21:22
mveCPallini2-Jun-09 21:22 
AnswerRe: How to design a decoder in C++? Pin
Stuart Dootson2-Jun-09 22:55
professionalStuart Dootson2-Jun-09 22:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.