473,699 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with identifiers

Hi,

I took this socket listener from the VC++.NET help file. I inserted it
in my project.

What library do I have to include to have those identifier working:
string,
int32,
Byte,
server,
TcpListener,
Console

I'm including those library:
#include <stdlib.h>
#include <string>
#include <winsock2.h>
using namespace std;

but it don't seem to resolve the problem.

My c++ is rusty, but I'll get over it, I just need a little help to pass
through that.

Thank you very much.

Marty

void main() {
try {
// Set the TcpListener on port 13000.
Int32 port = 13000;
IPAddress* localAddr = IPAddress::Pars e(S"127.0.0.1") ;

// TcpListener* server = new TcpListener(por t);
TcpListener* server = new TcpListener(loc alAddr, port);

// Start listening for client requests.
server->Start();

// Buffer for reading data
Byte bytes[] = new Byte[256];
String* data = 0;

// Enter the listening loop.
while (true) {
Console::Write( S"Waiting for a connection... ");

// Perform a blocking call to accept requests.
// You could also user server.AcceptSo cket() here.
TcpClient* client = server->AcceptTcpClien t();
Console::WriteL ine(S"Connected !");

data = 0;

// Get a stream Object* for reading and writing
NetworkStream* stream = client->GetStream();

Int32 i;

// Loop to receive all the data sent by the client.
while (i = stream->Read(bytes, 0, bytes->Length)) {
// Translate data bytes to a ASCII String*.
data = Text::Encoding: :ASCII->GetString(byte s, 0, i);
Console::WriteL ine(String::For mat(S"Received: {0}",
data));
// Process the data sent by the client.
data = data->ToUpper();

Byte msg[] = Text::Encoding: :ASCII->GetBytes(data) ;

// Send back a response.
stream->Write(msg, 0, msg->Length);
Console::WriteL ine(String::For mat(S"Sent: {0}", data));

}

// Shutdown and end connection
client->Close();
}
} catch (SocketExceptio n* e) {
Console::WriteL ine(S"SocketExc eption: {0}", e);
}

Console::WriteL ine(S"\nHit enter to continue...");
Console::Read() ;
}
Nov 17 '05 #1
1 1038

Marty wrote:
Hi,

I took this socket listener from the VC++.NET help file. I inserted it in my project.

What library do I have to include to have those identifier working:
string,
int32,
Byte,
server,
TcpListener,
Console

I'm including those library:
#include <stdlib.h>
#include <string>
#include <winsock2.h>
using namespace std;

but it don't seem to resolve the problem.

My c++ is rusty, but I'll get over it, I just need a little help to pass through that.


This code is using .NET classes, therefore you need to use managed
extensions to use it (compile with /clr).

When using managed classes, you don't use #include files, rather you
#use assemblies, then add using namespace statements :
#using <mscorlib.dll >
#using <system.dll>

using namespace System;
using namespace System::Net::So ckets;

you could replace the #using <assembly> statements with /AI compiler
flags.

Arnaud
MVP - VC

Nov 17 '05 #2

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

Similar topics

17
1747
by: Doug Fort | last post by:
This is an excerpt from a much longer post on the python-dev mailing list. I'm responding here, to avoid cluttering up python-dev. <snip> >Some English readers might not really imagine, but it is a constant >misery, having to mangle identifiers while documenting and thinking >in languages other than English, merely because the Python notion of >letter is limited to the English subset. Granted, keywords and standard >library use...
3
8012
by: skumar | last post by:
I am a newbie with C++ and unable to understand this warning/error message : localhost > g++ -Wall j++.cpp In file included from /usr/include/c++/3.2.2/backward/iostream.h:31, from j++.cpp:2: /usr/include/c++/3.2.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include...
0
2012
by: Leszek Dubiel | last post by:
----------------------------------------- BACKGROUND In my company (www.glass.biz) we use ERP software to compute what has to be done to do products for our customers. Main algorithm takes data in form of two tables -- let's call them "Structure" and "Orders". "Structure" keeps information on construction
2
1428
by: Andrea Gelsogroove | last post by:
Hi guys this is my problem : I have created a js function where I can add fields on the fly, but there seems to be a small flaw with Mozilla. If you try to click on "Add" button you can see that for every click there is a new text field and this is really useful because I don't need to refresh the page every time. It works 100% fine with Internet Explorer but in Mozilla it seems to loose the values I type in in field 2 or field 3 etc.
4
5328
by: Erwin Gabler | last post by:
Trying to validate a document with a reference to a DTD ("PUBLIC" identifier): <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE systems-description PUBLIC "-//foo/nono" ""> .... The DTD uses some kind of parameter entity with a reference to an entity file:
0
3935
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
14
1379
by: Army1987 | last post by:
#include <string.h> #include <stdlib.h> #include <stdio.h> char *_(char *str1, char *str2) { char *res; res = malloc((strlen(str1)+strlen(str2))*sizeof(char)); strcpy(res, str1); strcpy(res+strlen(str1), str2); return res;
399
12824
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or to python-3000@python.org In summary, this PEP proposes to allow non-ASCII letters as identifiers in Python. If the PEP is accepted, the following identifiers would also become valid as class, function, or variable names: Löffelstiel,...
3
3056
by: Antonio Rivas | last post by:
Hello all. I've got a problem of multiple definition in a program that at first glance looks correct (I won't type the whole code, just the relevant one and as examples since seems is a linkage problem): main.cpp ======== using namespace std; ....
2
1907
by: nd.sundar | last post by:
Hi, I have a collection of C source files (.c and .h). I need to find all identifiers which are used in that collection but not defined within the collection. The identifiers include pre-processor macros/ defines, structure types, and variable/function names. Thus, if a file uses a symbol A but no file in the collection defines A, then A should appear in the list. ctags comes close, but its -x option produces only a list of defined...
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.