473,395 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

errors

hi

i have msdn tcp/ip sample :

#include "stdafx.h"
//int _tmain(int argc, _TCHAR* argv[])
//{
// return 0;
//}

#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, IPPROTO_TCP );

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( 27015 );

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

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

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

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

WSACleanup();
return;
}

iam trying to compile this code on Visual studio 2005 express edition
with PlatformSDK (winxp)
i have this errors:

------ Build started: Project: 2223, Configuration: Debug Win32 ------
Compiling...
2223.cpp
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(334) : warning C4005:
'__reserved' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(702) : see previous definition of '__reserved'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(341) : warning C4005:
'__checkReturn' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(703) : see previous definition of '__checkReturn'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(344) : warning C4005:
'__typefix' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(704) : see previous definition of '__typefix'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(349) : warning C4005:
'__override' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(705) : see previous definition of '__override'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(350) : warning C4005:
'__fallthrough' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(714) : see previous definition of '__fallthrough'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(351) : warning C4005:
'__callback' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(706) : see previous definition of '__callback'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(352) : warning C4005: '__in' :
macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(499) : see previous definition of '__in'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(353) : warning C4005: '__out' :
macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(508) : see previous definition of '__out'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(354) : warning C4005: '__inout'
: macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(527) : see previous definition of '__inout'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(356) : warning C4005:
'__out_ecount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(509) : see previous definition of '__out_ecount'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(357) : warning C4005:
'__in_ecount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(500) : see previous definition of '__in_ecount'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(358) : warning C4005:
'__inout_ecount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(528) : see previous definition of '__inout_ecount'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(359) : warning C4005:
'__out_bcount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(510) : see previous definition of '__out_bcount'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(360) : warning C4005:
'__in_bcount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(501) : see previous definition of '__in_bcount'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(361) : warning C4005:
'__inout_bcount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(529) : see previous definition of '__inout_bcount'
c:\documents and settings\администратор\мои
документы\visual studio 2005\projects\2223\2223\2223.cpp(51) :
warning C4267: 'argument' : conversion from 'size_t' to 'int', possible
loss of data
c:\documents and settings\администратор\мои
документы\visual studio 2005\projects\2223\2223\2223.cpp(62) :
error C2043: illegal break
Build log was saved at "file://c:\Documents and
Settings\Администратор\Мои документы\Visual
Studio 2005\Projects\2223\2223\Debug\BuildLog.htm"
2223 - 1 error(s), 16 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========

Whats wrong ?

Jun 28 '06 #1
2 4913
errmaker wrote:
hi

i have msdn tcp/ip sample :

#include "stdafx.h"
//int _tmain(int argc, _TCHAR* argv[])
//{
// return 0;
//}

#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, IPPROTO_TCP );

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( 27015 );

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

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

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

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

WSACleanup();
return;
}

iam trying to compile this code on Visual studio 2005 express edition
with PlatformSDK (winxp)
i have this errors:

------ Build started: Project: 2223, Configuration: Debug Win32 ------
Compiling...
2223.cpp
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(334) : warning C4005:
'__reserved' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(702) : see previous definition of '__reserved'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(341) : warning C4005:
'__checkReturn' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(703) : see previous definition of '__checkReturn'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(344) : warning C4005:
'__typefix' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(704) : see previous definition of '__typefix'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(349) : warning C4005:
'__override' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(705) : see previous definition of '__override'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(350) : warning C4005:
'__fallthrough' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(714) : see previous definition of '__fallthrough'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(351) : warning C4005:
'__callback' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(706) : see previous definition of '__callback'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(352) : warning C4005: '__in' :
macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(499) : see previous definition of '__in'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(353) : warning C4005: '__out' :
macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(508) : see previous definition of '__out'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(354) : warning C4005: '__inout'
: macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(527) : see previous definition of '__inout'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(356) : warning C4005:
'__out_ecount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(509) : see previous definition of '__out_ecount'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(357) : warning C4005:
'__in_ecount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(500) : see previous definition of '__in_ecount'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(358) : warning C4005:
'__inout_ecount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(528) : see previous definition of '__inout_ecount'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(359) : warning C4005:
'__out_bcount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(510) : see previous definition of '__out_bcount'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(360) : warning C4005:
'__in_bcount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(501) : see previous definition of '__in_bcount'
c:\program files\microsoft visual studio
8\vc\platformsdk\include\specstrings.h(361) : warning C4005:
'__inout_bcount' : macro redefinition
c:\program files\microsoft visual studio
8\vc\include\sal.h(529) : see previous definition of '__inout_bcount'
c:\documents and settings\администратор\мои
документы\visual studio 2005\projects\2223\2223\2223.cpp(51) :
warning C4267: 'argument' : conversion from 'size_t' to 'int', possible
loss of data
c:\documents and settings\администратор\мои
документы\visual studio 2005\projects\2223\2223\2223.cpp(62) :
error C2043: illegal break
Build log was saved at "file://c:\Documents and
Settings\Администратор\Мои документы\Visual
Studio 2005\Projects\2223\2223\Debug\BuildLog.htm"
2223 - 1 error(s), 16 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========

Whats wrong ?


This likely is not a standard C++ issue (as hinted at by the double
underscores in the conflicting identifiers), so you'll want to take it
to a Microsoft group. See this FAQ for some possibilities:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Cheers! --M

Jun 28 '06 #2
errmaker wrote:
hi

i have msdn tcp/ip sample :

#include "stdafx.h"
//int _tmain(int argc, _TCHAR* argv[])
//{
// return 0;
//}

#include "winsock2.h"

void main() {

[redacted]


void main() is illegal. The program is ill formed, and therefore any
other problems are irrelevant.
Jun 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: mikey_boy | last post by:
Hello! Curious if anyone could give me a hand. I wrote this PHP script with makes a simple connection to a mysql database called firstdb and just pulls back the results and displays on the...
2
by: Trev | last post by:
SQL Server 2000 BE, Access 2002 FE. I want to write a stored procedure, that will among other things log errors to a table, I want to be able to report a summary of work done and errors to the...
10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
0
by: doli | last post by:
Hi, I have the following piece of code which iterates through the potential errors: i =0 For Each error_item in myConn.Errors DTSPackageLog.WriteStringToLog myConn.Errors(i).Description...
4
by: johnb41 | last post by:
I have a form with a bunch of textboxes. Each text box gets validated with the ErrorProvider. I want the form to process something ONLY when all the textboxes are valid. I found a solution,...
2
by: Samuel R. Neff | last post by:
Within the past few weeks we've been getting a lot of compiler errors in two classes when no errors actually exist. The error always reports as Name '_stepResizeRelocator' is not declared. ...
24
by: pat | last post by:
Hi everyone, I've got an exam in c++ in two days and one of the past questions is as follows. Identify 6 syntax and 2 possible runtime errors in this code: class demo {
8
by: ImOk | last post by:
I just have a question about trapping and retrying errors especially file locking or database locks or duplicate key errors. Is there a way after you trap an error to retry the same line that...
0
by: clemrock | last post by:
Help w/ errors.add_to_base between controller and model Hello, I'm having trouble in routing some errors between model and controller. The errors produced in the controller...
2
by: =?Utf-8?B?UmFuZHlz?= | last post by:
This just started when I updated to sp 1 working on a APS.net, Visual Studio 2008, c# Project. When I open a project, I get tons of Errors showing in the list 300+ if I double click on them I go...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.