Joke Collection Website - Blessing messages - How to send short messages with vb

How to send short messages with vb

This code is sent and received in MSDN6.0. Type Winsock control in the index, and then click Winsock control.

In which UDP

Protocol is a connectionless protocol, and the transmission between two computers is similar to the delivery of mail: messages are sent from one computer to another, but there is no clear connection between them. In addition, the maximum amount of data transmitted at a time depends on the specific network.

To create a UDP partner, follow these steps:

Create a new standard EXE project.

Change the name of the default form to frmPeerA.

Change the title of the table to "Peer A".

Place a Winsock control in the form and name it udpPeerA.

On the Properties page, click Protocol and modify the protocol to UDPProtocol.

Add two TextBox controls to the form. Name the first one txtSend and the second one txtOutput.

Add the following code to the form.

Private? Sub? Form_Load()

The name of the control is. Udpera

With what? Udpera

Important: you must put? RemoteHost? The value of

Change to the name of the computer.

. RemoteHost=? " PeerB "?

. RemotePort? =? 100 1? Port number of the connection.

. Binding? "1002" is bound to the local port.

End? along with

frmPeerB。 Show? Show the second form.

End? submarine

Private? Sub? txtSend_Change()

Send text as you type.

Upera. Send data? txtSend。 text

End? submarine

Private? Sub? udpPeerA_DataArrival? _

(ByVal? bytesTotal? As? Dragon)

Dim? strData? As? line

Upera. GetData? strData

txtOutput。 Words? =? strData

End? Sub To create a second UDP partner, please follow these steps:

Add a standard form to the project.

Change the name of the form to frmPeerB.

Change the title of the table to "Peer B".

Place a Winsock control in the form and name it udpPeerB.

On the Properties page, click Protocol and modify the protocol to UDPProtocol.

Add two TextBox controls to the form. Name the first one txtSend and the second one txtOutput.

Add the following code to the form.

Private? Sub? Form_Load()

The name of the control is. udpPeerB .

With what? udpPeerB

Important: you must put? RemoteHost? Change the value of to

The name of the computer.

. RemoteHost=? "Pyrah"

. RemotePort? =? 1002' port to be connected.

. Binding? "100 1" is bound to the local port.

End? along with

End? submarine

Private? Sub? txtSend_Change()

Send text immediately after typing.

udpPeerB。 Send data? txtSend。 text

End? submarine

Private? Sub? udpPeerB_DataArrival? _

(ByVal? bytesTotal? As? Dragon)

Dim? strData? As? line

udpPeerB。 GetData? strData

txtOutput。 Words? =? strData

End? submarine