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

Send message to TCP device

We have an Intermec stationary computers setup to basically clock people in
and out... I have code running (borrowed from Planet Source Code and
modified to suit) to receive packets from these computers each time someone
swipes their card. The code sends back a response to the device with
basically a clocked in/out successful/unsucessful message. This works good,
but the code will only send a message to the device if it receives a stream
from it first. I need to be able to send a message to the device,
un-prompted. Here is an example of the working code... on the line
identified is where the code stops and waits for a stream from the device..
I need to bypass this wait section and go right to the 'Stream.write' line..
but since the stream is dependent on the Tcpclient... which is waiting for a
message... :o)

\\
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim bytes(1024) As [Byte]
Dim data As [String] = Nothing
Dim stream As Sockets.NetworkStream
Dim Clock As New
Sockets.TcpListener(Dns.GetHostByName("10.100.4.29 ").AddressList(0), 33)
Dim client As Sockets.TcpClient
Dim msg As Byte()

Clock.Start()

client = Clock.AcceptTcpClient ' <--- Program stops here to
listen for a stream from 'Clock'

stream = client.GetStream()
msg = System.Text.Encoding.ASCII.GetBytes(TextBox1.Text)
stream.Write(msg, 0, msg.Length)
Clock.Stop()
End Sub
//

Thanks!

Matt
Nov 21 '05 #1
1 1822
I think you could set up a TcpClient on another thread and connect to the
device, and then send it a message. Of course, the device would have to be
listening for it.
-Brian

"Matt" wrote:
We have an Intermec stationary computers setup to basically clock people in
and out... I have code running (borrowed from Planet Source Code and
modified to suit) to receive packets from these computers each time someone
swipes their card. The code sends back a response to the device with
basically a clocked in/out successful/unsucessful message. This works good,
but the code will only send a message to the device if it receives a stream
from it first. I need to be able to send a message to the device,
un-prompted. Here is an example of the working code... on the line
identified is where the code stops and waits for a stream from the device..
I need to bypass this wait section and go right to the 'Stream.write' line..
but since the stream is dependent on the Tcpclient... which is waiting for a
message... :o)

\\
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim bytes(1024) As [Byte]
Dim data As [String] = Nothing
Dim stream As Sockets.NetworkStream
Dim Clock As New
Sockets.TcpListener(Dns.GetHostByName("10.100.4.29 ").AddressList(0), 33)
Dim client As Sockets.TcpClient
Dim msg As Byte()

Clock.Start()

client = Clock.AcceptTcpClient ' <--- Program stops here to
listen for a stream from 'Clock'

stream = client.GetStream()
msg = System.Text.Encoding.ASCII.GetBytes(TextBox1.Text)
stream.Write(msg, 0, msg.Length)
Clock.Stop()
End Sub
//

Thanks!

Matt

Nov 21 '05 #2

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

Similar topics

2
by: Lisa Pearlson | last post by:
Hi, My php application (on Apache/Linux) needs to do the following: The PHP script receives a request from a client (binary), asking for certain records of data. My PHP script loops through...
1
by: Steve | last post by:
Please take a look at the simple code segment below and advise me what is wrong. According to the help and examples I've seen it should work unless I misunderstand something. The problem is...
3
by: Sara | last post by:
HI, I want to code a program to detect GSM mobile (any kind) which connected through serial port to computer and then be able to send SMS through this mobile phone to other mobile phones, could...
5
by: AAVarda | last post by:
Hi, I have a device that scan's a doc and send's the doc image back. Below is the function in API to get the Image: ULONG MTMICRGetImage ( char *pcDevName, char *pcImageID, char *pcBuffer,...
3
by: vorange | last post by:
Hello, I have a problem I have been unable to solve for quite some time now. I'm using the Serialport class and opening the port and writing a byte to it. The byte is successfully received by...
6
by: terry | last post by:
Hi, I am trying to send a character to '/dev/ttyS0' and expect the same character and upon receipt I want to send another character. I tired with Pyserial but in vain. Test Set up: 1. Send...
4
by: Eran.Yasso | last post by:
Hi all, I am trying to write application which runs on my PC that sends data to an application running on Windows mobile. The problem is that the tcp over activesync doesn't work. The device is...
1
by: Blokker1999 | last post by:
Hello, I am new to VB.net and I am trying to write a program to interface with a device. I have most of the protocol documented. Thanks to this forum I am already able to send information to the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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.