Click here to Skip to main content
15,914,820 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: add " to a string Pin
Cedric Moonen7-Apr-08 3:13
Cedric Moonen7-Apr-08 3:13 
GeneralRe: add " to a string Pin
ptr_Electron7-Apr-08 3:17
ptr_Electron7-Apr-08 3:17 
GeneralRe: add " to a string Pin
Cedric Moonen7-Apr-08 3:23
Cedric Moonen7-Apr-08 3:23 
QuestionRe: add " to a string Pin
CPallini7-Apr-08 3:14
mveCPallini7-Apr-08 3:14 
GeneralRe: add " to a string Pin
ptr_Electron7-Apr-08 3:16
ptr_Electron7-Apr-08 3:16 
QuestionRe: add " to a string Pin
CPallini7-Apr-08 3:23
mveCPallini7-Apr-08 3:23 
GeneralRe: add " to a string Pin
David Crow7-Apr-08 3:37
David Crow7-Apr-08 3:37 
Generalsocket proramming Pin
ADTC#6-Apr-08 22:34
ADTC#6-Apr-08 22:34 
When i execute the code given below in C on Visual Studio 2008 i get the following error messages
1>------ Build started: Project: socketclientc, Configuration: Debug Win32 ------
1>Compiling...
1>client.c
1> c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(872) : see declaration of 'WSACleanup'
1>c:\documents and settings\hp\my documents\visual studio 2008\projects\socketclientc\socketclientc\client.c(69) : error C2059: syntax error : 'return'
1>c:\documents and settings\hp\my documents\visual studio 2008\projects\socketclientc\socketclientc\client.c(70) : error C2059: syntax error : '}'
1>Build log was saved at "file://c:\Documents and Settings\HP\My Documents\Visual Studio 2008\Projects\socketclientc\socketclientc\Debug\BuildLog.htm"
1>socketclientc - 25 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

// practiceclient.c : Defines the entry point for the console application.
#include <stdio.h>
#include <winsock2.h>

int main()
{
WSADATA wsadata;
WORD wVersion;
int wsaerr;
wVersion = MAKEWORD(2,2);
wsaerr = WSAStartup(wVersion, &wsadata);
if(wsaerr != 0)
{
printf("There is a DLL linker problem");
return 0 ;
}
else
printf("\nDLL working and compatible!!");
SOCKET mysocket;
mysocket = socket(AF_INET,SOCK_STREAM,0);
if(mysocket == SOCKET_ERROR)
{
printf("socket cannote be created error: %d",WSAGetLastError);
WSACleanup();
return 0;
}
printf("\nSocket created successfully");
sockaddr_in Cservice;
Cservice.sin_family = AF_INET;
Cservice.sin_addr.s_addr = inet_addr("127.0.0.1");
Cservice.sin_port = htons(55555);
if(connect(mysocket,(sockaddr *)&Cservice,sizeof(Cservice))== SOCKET_ERROR)
{
printf("Connect is unsuccessful, error:%d",WSAGetLastError);
WSACleanup();
getchar();
return 0;
}
int bytesent;
int byterecv=SOCKET_ERROR;
char sendbuff[200] = "Client:This is a test string from client.";
char recvbuff[200] = "";
while(byterecv == SOCKET_ERROR)
{
byterecv = recv(mysocket,recvbuff,strlen(recvbuff),0);
if(byterecv==0||byterecv==WSAECONNRESET)
printf("\nClient: Connection closed");
if(byterecv>0)
return 0;
else
{
printf("\nClient: recv() is OK");
printf("\nClient: The string received %s",recvbuff);
printf("\nClient: The bytes received %d",byterecv);
}
}
bytesent=send(mysocket,sendbuff,strlen(sendbuff),0);
if(bytesent == SOCKET_ERROR)
printf("\nClient: send() failed:%d",WSAGetLastError);
else
{
printf("\n Client: send() is OK");
printf("\n Client: The string sent %s",sendbuff);
printf("\n Client: The number of bytes sent %d",bytesent);
}

getchar();
WSACleanup();
return 0;
}
GeneralRe: socket proramming Pin
Cedric Moonen6-Apr-08 23:08
Cedric Moonen6-Apr-08 23:08 
QuestionRe: socket proramming Pin
ADTC#7-Apr-08 1:50
ADTC#7-Apr-08 1:50 
GeneralRe: socket proramming Pin
Cedric Moonen7-Apr-08 3:04
Cedric Moonen7-Apr-08 3:04 
GeneralRe: socket proramming Pin
ADTC#7-Apr-08 20:31
ADTC#7-Apr-08 20:31 
GeneralRe: socket proramming Pin
James R. Twine7-Apr-08 3:44
James R. Twine7-Apr-08 3:44 
GeneralRe: socket proramming Pin
Nitheesh George7-Apr-08 4:46
Nitheesh George7-Apr-08 4:46 
GeneralRe: socket proramming Pin
ADTC#7-Apr-08 18:29
ADTC#7-Apr-08 18:29 
GeneralRe: socket proramming Pin
ADTC#7-Apr-08 20:31
ADTC#7-Apr-08 20:31 
QuestionHow to resize window automatic. Pin
Y_Kaushik6-Apr-08 21:35
Y_Kaushik6-Apr-08 21:35 
AnswerRe: How to resize window automatic. Pin
Cedric Moonen6-Apr-08 21:49
Cedric Moonen6-Apr-08 21:49 
GeneralRe: How to resize window automatic. Pin
Y_Kaushik6-Apr-08 22:51
Y_Kaushik6-Apr-08 22:51 
GeneralRe: How to resize window automatic. Pin
Cedric Moonen6-Apr-08 23:04
Cedric Moonen6-Apr-08 23:04 
GeneralRe: How to resize window automatic. Pin
ThatsAlok7-Apr-08 2:49
ThatsAlok7-Apr-08 2:49 
AnswerRe: How to resize window automatic. Pin
ThatsAlok6-Apr-08 22:41
ThatsAlok6-Apr-08 22:41 
AnswerRe: How to resize window automatic. Pin
David Crow7-Apr-08 3:56
David Crow7-Apr-08 3:56 
AnswerRe: How to resize window automatic. Pin
Nitheesh George7-Apr-08 5:41
Nitheesh George7-Apr-08 5:41 
AnswerRe: How to resize window automatic. Pin
Hamid_RT8-Apr-08 7:22
Hamid_RT8-Apr-08 7:22 

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.