473,385 Members | 1,317 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,385 software developers and data experts.

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 9168
Hi,

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

"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:Cp*******************@fe2.news.blueyonder.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(yourASCIIstring);

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*********************@g44g2000cwa.googlegro ups.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(yourASCIIstring);

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.GetHostEntry ("www.contoso.com").AddressList[0];

tcpClient.Connect (ipAddress, 11003);

NetworkStream netStream = tcpClient.GetStream ();

if (netStream.CanWrite)
{
Byte[] sendBytes = Encoding.UTF8.GetBytes ("Is anybody there?");
netStream.Write (sendBytes, 0, sendBytes.Length);
}

--
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
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...
3
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...
7
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...
4
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...
2
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. ...
19
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...
9
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...
2
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...
10
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>...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.