Hi guys,
Just want to ask how can I send data serially? I have here a sample code but I use sockets and tcpclient class but I'm wondering how to do it using serial cable.Any idea? - Private Sub SendData(ByVal IpAdd As String, ByVal sData As String)
-
-
Dim myIpAdd As System.Net.IPAddress
-
Dim myPort As Integer = 4003
-
-
'Convert data String to Byte()
-
Dim pBytes() As Byte = Encoding.Default.GetBytes(sData)
-
'Debug:
-
'Dim pBytes() As Byte = Encoding.ASCII.GetBytes(sData)
-
-
'create a socket
-
Dim isocket As Socket
-
isocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
-
-
'convert string ip to IPAddress
-
myIpAdd = IPAddress.Parse(IpAdd)
-
-
'Debug:
-
'Dim temp As String = myIpAdd.ToString()
-
'Dim ret = IPAddress.TryParse(IpAdd, temp)
-
-
'connect to remote host
-
Try
-
isocket.Connect(myIpAdd, myPort)
-
If isocket.Connected() Then
-
-
'Send Data
-
isocket.Send(pBytes)
-
-
'Debug
-
'MsgBox("Sent... ")
-
-
'close connection
-
isocket.Close()
-
-
End If
-
-
Catch se As SocketException
-
MsgBox("Socket Exception")
-
-
Catch ex As Exception
-
MsgBox("UnExpected exception")
-
-
End Try
-
-
End Sub
Thanks
3 1933
Hi,
I have never tried this, BUt got some good looking links link1 link2
hope it helps
Hi,
I have never tried this, BUt got some good looking links link1 link2
hope it helps
thanks for this link...Anyway, did you experience sending data using sockets and tthe data is distorted? I just saw it today when I delete MsgBox which inform me that data is sent/failed. I think I need to add delay before sending the next one? Do you know the how to add delay or sleep in .net?
thanks for this link...Anyway, did you experience sending data using sockets and tthe data is distorted? I just saw it today when I delete MsgBox which inform me that data is sent/failed. I think I need to add delay before sending the next one? Do you know the how to add delay or sleep in .net?
Thread.Sleep(ti me) will put the current operation to sleep
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Quarco |
last post by:
Hi,
Quick & simple question:
I have to send the next data to a socket in order to make a popup visible on
a windows machine..
TITLE Title of popup
TEXT Text in popup
POPUP
|
by: Anne |
last post by:
hi ng
I would like to make a database where the user automatically can send a
short message service (SMS) just by pressing a button. I know how to do it
if it is an email (by using the docmd.sendobject method) - but what code do
I need to send a SMS
Thanks in advance
Anne
|
by: Gregory Hassett |
last post by:
Hello,
I want to periodically send a TCP packet to a peer, always from the same
source port. That is, each packet will come from my local ip address, port
8801, and go to the peer's ip address, to HIS port 8801.
This means that I need to bind my sender socket to (myaddress,8801), use it
for the send, then shut it down and close it. Then...
|
by: eliss.carmine |
last post by:
I'm using TCP/IP to send a Bitmap object over Sockets. This is my first
time using C# at all so I don't know if this is the "right" way to do
it. I've already found out several times the way I was doing something
was really inefficient and could reduce 10 lines of code with 2, etc.
For reading, I am using a TcpClient and I call
...
|
by: Jason |
last post by:
Hello
I've got some test code that I've found on the web that is a TCP server and
a TCP client. The server sends data to the client on the port i specify. I
know because get the port number through an IPEndPoint. However when I send
the data back to the server, the server receives it on a different port
number then what I specify, and I...
| |
by: danfolkes |
last post by:
Hey Everyone, I am trying to send repeated messages from a "Node" to a
"Server". It works the first time I send the from the Node to Server,
but after that it either errors, or does not do anything.
I would love some help, here is the code:
import socket
import thread
import time
|
by: danfolkes |
last post by:
Why does the message send only once?
The node sends once, then fails after that.
<code>
import socket
import thread
import time
def Node(nodeAddress):
|
by: Rob Dob |
last post by:
The following code is giving me a timeout problem., no matter what I do I
can't send a piece of mail using .net2.0 System.Net.Mail.SmtpClient via port
465 and using ssl, if however I try using outlook or outlook express it
works fine..
System.Net.Mail.MailMessage msgMail = new
System.Net.Mail.MailMessage("myemail@mydomain.com",...
|
by: Xionbox |
last post by:
Hello everybody,
The error I have seems very easy to solve, but for some odd reason I can't seem to solve it. Anyways, here's my "setup".
I created a server running on localhost:1200 (telnet localhost 1200 proves that it is up and running) and I coded a client which is supposed to connect to that server and send it data.
The odd part is...
|
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. ...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |