Hello There, Guest!
View New Posts  |  View Today's Posts
[VB.Net] Multi-Client Server Async Socket Example

ii 
  • 4 Vote(s) - 4.5 Average


03-05-2012, 05:53 PM #21
KoBE
¯\_(ツ)_/¯
******
Global Moderators
Posts: 4,862 Threads:494 Joined: Jun 2011 Reputation: 67

RE: Multi-Client Server Async Socket Example
In this example, the server is the one sending the messages to the client.

If you would like the client to send messages to the server see these lines from the server project:
Code:
    Private Sub Send(ByVal msg As String, ByVal client As Socket)
        'get bytes to send
        Dim sendBytes As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(msg)
        'begin sending (notice the client is sent as an AsyncState)

        client.BeginSend(sendBytes, 0, sendBytes.Length, SocketFlags.None, New AsyncCallback(AddressOf OnSend), client)
    End Sub
    Private Sub OnSend(ByVal ar As IAsyncResult)
        'create a temp socket to use for our client
        Dim client As Socket = ar.AsyncState
        client.EndSend(ar)
    End Sub

03-08-2012, 12:46 PM #22
qwer
Junior Member
**
Posts: 1 Threads:0 Joined: Mar 2012 Reputation: 0

RE: Multi-Client Server Async Socket Example
great app..
Great Job, But what if I need to send data back to the server from one of the clients? i have not been able to get it to work, any ideas?

03-08-2012, 01:22 PM #23
KoBE
¯\_(ツ)_/¯
******
Global Moderators
Posts: 4,862 Threads:494 Joined: Jun 2011 Reputation: 67

RE: Multi-Client Server Async Socket Example
Please see the post directly above yours.

03-08-2012, 11:09 PM #24
jackvald
Junior Member
**
Posts: 6 Threads:0 Joined: Feb 2012 Reputation: 0

RE: Multi-Client Server Async Socket Example
Hi!!, the app looks great, thanks for this post!
I've used VB before for several projects but I'm not very familiar with VB for ethernet applications.
For an school project I need to use a 2 or more serial to ethernet modules (Wiznet wiz105SR) in order to communicate this devices with the PC. I tried to use the example you posted but it didn't work, would you give me some tips?? Thanks in advance.

03-08-2012, 11:11 PM #25
AceInfinity
Developer
*******
Administrators
Posts: 9,733 Threads:1,026 Joined: Jun 2011 Reputation: 76

RE: Multi-Client Server Async Socket Example
Are you using R32 to connect to the devices? I've never heard of this "Wiznet wiz105SR" thing before. Without this device though it would be hard for me to test bits of code to see what works and what doesn't or how it interprets messages from the machine. I used to do a bit of R32 programming though with Visual Automation.
This post was last modified: 03-08-2012, 11:12 PM by AceInfinity.


Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer

Development Site: aceinfinity.net

 ▲
 ▲ ▲

03-13-2012, 10:39 PM #26
jackvald
Junior Member
**
Posts: 6 Threads:0 Joined: Feb 2012 Reputation: 0

RE: Multi-Client Server Async Socket Example
(03-08-2012, 11:11 PM)AceInfinity Wrote:  Are you using R32 to connect to the devices? I've never heard of this "Wiznet wiz105SR" thing before. Without this device though it would be hard for me to test bits of code to see what works and what doesn't or how it interprets messages from the machine. I used to do a bit of R32 programming though with Visual Automation.
I think it doesn't matter you haven't heard of that device before, i just would like to know how to receive data from an ethernet port.

03-13-2012, 11:19 PM #27
AceInfinity
Developer
*******
Administrators
Posts: 9,733 Threads:1,026 Joined: Jun 2011 Reputation: 76

RE: Multi-Client Server Async Socket Example
See here's similarly what I used to work with:
http://www.lvr.com/serial_ports_dotnet.htm

I just did a search for the first time, but this should be useful enough for you. Are you planning on taking a look at KoBE's client example here as well later?

Edit: R32 lol... *RS-232, mistake on that one.

Different devices have different protocols, therefore, it may, or may not, be essential that people here have worked with that device before.
This post was last modified: 03-13-2012, 11:21 PM by AceInfinity.


Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer

Development Site: aceinfinity.net

 ▲
 ▲ ▲

03-19-2012, 04:10 PM #28
jackvald
Junior Member
**
Posts: 6 Threads:0 Joined: Feb 2012 Reputation: 0

RE: Multi-Client Server Async Socket Example
(03-13-2012, 11:19 PM)AceInfinity Wrote:  Hi!!!
Thanks a lot for your help!!!

Finally I could connect the device (wiznet) and see the winznet's ip address in the window that appears when you run "serer.exe" (KoBE's code). The only thing that I would like to know now is how to receive a message from several clients to the server in order to see that message displayed in the window.

I would appreciate a lot if you or KoBE or anyone else in this forum could help me with this.
Thanks in advance!!


03-19-2012, 04:19 PM #29
KoBE
¯\_(ツ)_/¯
******
Global Moderators
Posts: 4,862 Threads:494 Joined: Jun 2011 Reputation: 67

RE: Multi-Client Server Async Socket Example
http://tech.reboot.pro/showthread.php?ti...4#pid16994

Its the same concept. For sending to the server as it is sending to the client.

03-19-2012, 05:20 PM #30
jackvald
Junior Member
**
Posts: 6 Threads:0 Joined: Feb 2012 Reputation: 0

RE: Multi-Client Server Async Socket Example
(03-19-2012, 04:19 PM)KoBE Wrote:  Its the same concept. For sending to the server as it is sending to the client.
thanks!! now with that the client is able to send messages, but where does the server receive those messages???


ii 


Forum Jump:


Possibly Related Threads...
Thread Author Replies Views Last Post
Exclamation  problem multi post + httpwebrequest read ip sharokurdi 1 1,202 11-11-2016, 06:39 PM
Last Post: AceInfinity
   Create your own IRC Client [C#/VB.Net] KoBE 185 116,368 10-01-2016, 06:57 PM
Last Post: AceInfinity
   IRC Client Class KoBE 110 71,655 10-01-2016, 06:52 PM
Last Post: AceInfinity
  Telnet Client AceInfinity 5 2,647 06-05-2016, 07:48 PM
Last Post: AceInfinity
   Twitch chat bot (irc client) dmgvol 11 18,945 08-24-2015, 11:59 PM
Last Post: Signal_20


Users browsing this thread: 1 Guest(s)