473,765 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending ASCII character string / stream to an IP address

Hi
I want to send an ASCII character string / stream to an IP address.

I basically have 6 barcode printers, and a web interface.
Depending on what is entered on the web page, will determine which printer
the label is printed on (ie. which IP address the ASCII string / stream is
sent to).

How can I send an ASCII string / stream to an IP address??

Thanks
Feb 17 '06 #1
5 9253
Hi,

ASCIIEncoding.G etBytes will help you
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Paul Aspinall" <pa**@aspy.co.u k> wrote in message
news:Cp******** ***********@fe2 .news.blueyonde r.co.uk...
Hi
I want to send an ASCII character string / stream to an IP address.

I basically have 6 barcode printers, and a web interface.
Depending on what is entered on the web page, will determine which printer
the label is printed on (ie. which IP address the ASCII string / stream is
sent to).

How can I send an ASCII string / stream to an IP address??

Thanks

Feb 17 '06 #2
Paul,

I'm going to assume that you already have some way to pass information
worked out, either TCP, UDP, or something else. If this isn't so just
respond and I can help with that, but for now, to keep this short,
here's how to do what you want.

You want to parse your ASCII string into a byte array. Try this

byte[] data = Encoding.ASCII. GetBytes(yourAS CIIstring);

Now you have your ASCII string in a byte array that can be written to
the network anyway you choose. Does this help? If you wanted to know
how to actually send this byte array let me know.

Feb 17 '06 #3
Hi Justin,

Thanks for the help

Yes - do you have some code (any, but C# preferred), that will send this
string to an IP address??

Thanks
Paul

"JustinC" <ju***********@ gmail.com> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.com...
Paul,

I'm going to assume that you already have some way to pass information
worked out, either TCP, UDP, or something else. If this isn't so just
respond and I can help with that, but for now, to keep this short,
here's how to do what you want.

You want to parse your ASCII string into a byte array. Try this

byte[] data = Encoding.ASCII. GetBytes(yourAS CIIstring);

Now you have your ASCII string in a byte array that can be written to
the network anyway you choose. Does this help? If you wanted to know
how to actually send this byte array let me know.

Feb 17 '06 #4
Hello, Paul!

PA> How can I send an ASCII string / stream to an IP address??

TcpClient tcpClient = new TcpClient ();
IPAddress ipAddress = Dns.GetHostEntr y ("www.contoso.c om").AddressLis t[0];

tcpClient.Conne ct (ipAddress, 11003);

NetworkStream netStream = tcpClient.GetSt ream ();

if (netStream.CanW rite)
{
Byte[] sendBytes = Encoding.UTF8.G etBytes ("Is anybody there?");
netStream.Write (sendBytes, 0, sendBytes.Lengt h);
}

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 17 '06 #5
Paul,

The wau Vadym shows here is exactly the way you want to do it, provided
that your webservice is running on port 11003 and accepting TCP
connections. As for TCP, it probably is, but it could be running UDP.
As for the port, that's different for every web service, and your
webservice may also be accepting transmissions from several ports. Try
what he showed, but with using ASCII instead of UTF8, and if it doesn't
work just reply to this and we'll try something else.

Feb 17 '06 #6

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

Similar topics

4
8200
by: yaron | last post by:
Hi, I have a problem when sending data over TCP socket from c# client to java server. the connection established ok, but i can't send data from c# client to java server. it's work ok with TcpClient, NetworkStream and StreamWriter classes. but with low level socket it doesn't work (When using the Socket class Send method).
3
4689
by: Danny Tuppeny | last post by:
Hi all, I'm trying to send a null character as a string delimiter through a TcpClient (code below). It's to connect to this poker bot room: http://games.cs.ualberta.ca/webgames/poker/bots.html My code is as below, but I never get a response. I'm assuming my transmission is ending at the null character (the debug statement certainly only outputs up until the null character). Any ideas?
7
5566
by: Bob Garbados | last post by:
I need to construct an xml document, send it to a service over tcp/ip to a specified port, receive the xml response, and process the xml response. I can create the xml document to send, but what's the best way to move the data from an XmlDocument to a Byte array? Currently I paste the xml into a textbox and send it with the following code: Dim tcpClient As New System.Net.Sockets.TcpClient tcpClient.Connect("127.0.0.1", 10000) Dim...
4
2246
by: Robert McNally | last post by:
Hello, I'm currently learning c# and have been trying to write a simple program with sockets. The problem is i'm trying to send an email with an attachment, (which is the program itself) by using base64. When i run it it sends the email ok, but and attchment doesn't work i get an error when i run it. The attchment seems to be bigger (20k) then the orginal (16k) i've included the source which i have been using. Can someone tell me what...
2
5290
by: Alpha | last post by:
Hi, I'm able to make connection to a server using socket connection. However, when I send a command string the server just ignores it. All command string needs to start with "0xF9" at Byte 0. During the run-time debug, I see it to be "u" with a "~" on top of it. Is that OxF9? Can someone tell me what I'm doing wrong? Thanks, Alpha private void Connect(String server, String message) { //Socket Connect
19
11239
by: ... | last post by:
Hi I need to send a chr(255) to a serial port. When I send it, through comm.write (chr(255)) it sends a chr(63) ... in Hex, I write chr(&FF) and it actually sends chr(&3F) ... why does this happen, and how can I send it right ? I'm using vb.net 2005 express with framework 2.0 Thanks for an answear ...
9
4927
by: Miro | last post by:
VB 2003 at the end of the code, this works great. bytCommand = Encoding.ASCII.GetBytes("testing hello send text") udpClient.Send(bytCommand, bytCommand.Length) and this recieves it Dim strReturnData As String = _ System.Text.Encoding.ASCII.GetString(receiveBytes)
2
1661
by: luchyloo | last post by:
-------------------------------------------------------------------------------- What you have to implement You have a message that can be sent on a port. Before sending the message you have to encode the message to ASCII or Unicode as hexadecimal. Sending the message over the network as a continuous string stream is quite simple. The recipient simply has to decode the hexadecimal string and will know what the message is. The problem...
10
5097
by: Markgoldin | last post by:
I am sending an XML data from not dontnet process to a .Net via socket listener. Here is a data sample: <VFPData> <serverdata> <coderun>updateFloor</coderun> <area>MD2</area> <zone>BOXING</zone> <status>Running</status> <job>1000139233</job>
0
9568
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
10160
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...
1
9951
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
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
8831
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...
0
6649
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();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
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

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.