Click here to Skip to main content
15,890,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Answer[Msg Deleted] Pin
Christian Graus6-Sep-05 17:10
protectorChristian Graus6-Sep-05 17:10 
AnswerRe: Silent Crash On 2K - Debug Suggestions? Pin
Christian Graus6-Sep-05 17:10
protectorChristian Graus6-Sep-05 17:10 
GeneralRe: Silent Crash On 2K - Debug Suggestions? Pin
Paul Belikian6-Sep-05 18:58
Paul Belikian6-Sep-05 18:58 
GeneralRe: Silent Crash On 2K - Debug Suggestions? Pin
Christian Graus6-Sep-05 19:15
protectorChristian Graus6-Sep-05 19:15 
AnswerRe: Silent Crash On 2K - Debug Suggestions? Pin
Blake Miller7-Sep-05 9:49
Blake Miller7-Sep-05 9:49 
QuestionDisplay Unicode string in Win32 Console Pin
Le Tuan Anh6-Sep-05 16:49
Le Tuan Anh6-Sep-05 16:49 
Questionhow read another process of variable? Pin
00000000096-Sep-05 15:36
00000000096-Sep-05 15:36 
QuestionSend message Pin
Member 21610046-Sep-05 15:34
Member 21610046-Sep-05 15:34 
I just new in visual c++ and have a copy of server and client source code. The result after I compile show Bytes recv: 21, but I want to change it so that I can send what I type. Can help me...Below is the client source code:

#include "stdafx.h"
#include "winsock2.h"



void main()
{

// Initialize Winsock.
WSADATA wsaData;
int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
if ( iResult != NO_ERROR )
{
printf("Error at WSAStartup()\n");
}
// Create a socket.
SOCKET m_socket;
m_socket = socket( AF_INET, SOCK_STREAM, 0 );

if ( m_socket == INVALID_SOCKET )
{
printf( "Error at socket(): %ld\n", WSAGetLastError() );
WSACleanup();
return;
}

// Connect to a server.
sockaddr_in clientService;

clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr( "127.0.0.1" );
clientService.sin_port = htons( 60000 );

if ( connect( m_socket, (SOCKADDR*) &clientService, sizeof(clientService) ) == SOCKET_ERROR)
{
printf( "Failed to connect.\n" );
WSACleanup();
return;
}

// Send and receive data.
long bytesSent;
long bytesRecv = SOCKET_ERROR;
char sendbuf[300] = "Client: Sending data.";
char recvbuf[300] = "";

bytesSent = send( m_socket, sendbuf, lstrlen(sendbuf), 0 );
printf( "Bytes Sent: %ld\n", bytesSent );

while( bytesRecv == SOCKET_ERROR )
{
bytesRecv = recv( m_socket, recvbuf, 300, 0 );
if ( bytesRecv == 0 || bytesRecv == WSAECONNRESET )
{
printf( "Connection Closed.\n");
break;
}
if (bytesRecv < 0)
return;
printf( "Bytes Recv: %ld\n", bytesRecv );
}

return;
}
AnswerRe: Send message Pin
Christian Graus6-Sep-05 15:51
protectorChristian Graus6-Sep-05 15:51 
Questionusing GDI+ in C++ windows project Pin
mpastchenko6-Sep-05 13:51
mpastchenko6-Sep-05 13:51 
AnswerRe: using GDI+ in C++ windows project Pin
Christian Graus6-Sep-05 14:55
protectorChristian Graus6-Sep-05 14:55 
GeneralRe: using GDI+ in C++ windows project Pin
mpastchenko7-Sep-05 8:33
mpastchenko7-Sep-05 8:33 
GeneralRe: using GDI+ in C++ windows project Pin
mpastchenko7-Sep-05 9:10
mpastchenko7-Sep-05 9:10 
GeneralRe: using GDI+ in C++ windows project Pin
Christian Graus7-Sep-05 12:45
protectorChristian Graus7-Sep-05 12:45 
GeneralRe: using GDI+ in C++ windows project Pin
Christian Graus7-Sep-05 12:43
protectorChristian Graus7-Sep-05 12:43 
GeneralRe: using GDI+ in C++ windows project Pin
mpastchenko7-Sep-05 14:31
mpastchenko7-Sep-05 14:31 
GeneralRe: using GDI+ in C++ windows project Pin
Christian Graus7-Sep-05 14:34
protectorChristian Graus7-Sep-05 14:34 
GeneralRe: using GDI+ in C++ windows project Pin
mpastchenko7-Sep-05 15:39
mpastchenko7-Sep-05 15:39 
QuestionError in Release Build Only Pin
hamza56-Sep-05 13:48
hamza56-Sep-05 13:48 
AnswerRe: Error in Release Build Only Pin
ThatsAlok6-Sep-05 18:56
ThatsAlok6-Sep-05 18:56 
GeneralRe: Error in Release Build Only Pin
Anonymous7-Sep-05 6:57
Anonymous7-Sep-05 6:57 
AnswerRe: Error in Release Build Only Pin
Anonymous6-Sep-05 20:59
Anonymous6-Sep-05 20:59 
GeneralRe: Error in Release Build Only Pin
Anonymous7-Sep-05 6:58
Anonymous7-Sep-05 6:58 
QuestionTrouble with writing dll Pin
Christian Graus6-Sep-05 13:03
protectorChristian Graus6-Sep-05 13:03 
AnswerRe: Trouble with writing dll Pin
S Douglas6-Sep-05 23:20
professionalS Douglas6-Sep-05 23:20 

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.