PC Review


Reply
Thread Tools Rate Thread

Send message to TCP device

 
 
Matt
Guest
Posts: n/a
 
      22nd Jun 2005
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... )

\\
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QnJpYW4gSGF5bmVz?=
Guest
Posts: n/a
 
      22nd Jun 2005
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... )
>
> \\
> 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
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TCP or not TCP? Joseph Carrier Windows XP Networking 9 5th Sep 2004 09:40 AM
XP SP2 event ID 4226 - TCP/IP has reached the security limit imposed on the number of concurrent TCP connect attempts Torgeir Bakken \(MVP\) Windows XP Security 3 1st Sep 2004 07:48 PM
How to handle TCP checksum, if adapter support TCP checksum offloading? Rajesh Gupta Windows XP Drivers 0 3rd Aug 2004 12:20 AM
Clarification: using excel to send data to ethernet device over TCP/IP D. Miller Microsoft Excel Programming 0 27th Apr 2004 02:52 PM
Configuring TCP/IP Settings, Enable TCP/IP Boni Windows XP Networking 0 25th Jan 2004 01:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:27 PM.