473,326 Members | 2,081 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,326 software developers and data experts.

Multiple socket

Hello all

I am a newbie to VB.NET and i need a solution to the following problem

I have an application which listens to a port for incoming connections from
a client via a socket.

Upon a connection of a client i would like the application to call another
FORM which also has a socket, and i would like to transfer the first socket
information to the 2nd socket, hence allowing the client now to talk
directly to the 2nd socket,
and hence free up the initial socket to start listening again.

I have looked into some examples nad have a basic understanding of how
sockets work.

TIA


Nov 20 '05 #1
1 1193

"N.Naeem" <nn****@REMTHISportech.co.uk> wrote in message
news:3f***********************@auth.uk.news.easyne t.net...
Hello all

I am a newbie to VB.NET and i need a solution to the following problem

I have an application which listens to a port for incoming connections from a client via a socket.

Upon a connection of a client i would like the application to call another
FORM which also has a socket, and i would like to transfer the first socket information to the 2nd socket, hence allowing the client now to talk
directly to the 2nd socket,
and hence free up the initial socket to start listening again.

I have looked into some examples nad have a basic understanding of how
sockets work.


With only a basic understanding of sockets, you might want to work with the
TCP/IP helper classed TCPListener, TCPClient, and streams. Here's an
example of a simple telnet server.

David
Sub main()

Dim sl As New Net.Sockets.TcpListener(System.Net.IPAddress.Any, 23)
sl.Start()

Do
Dim tc As TcpClient = sl.AcceptTcpClient()
Threading.ThreadPool.QueueUserWorkItem(AddressOf converse, tc)
Loop
End Sub

Sub converse(ByVal o As Object)
Dim tc As TcpClient = DirectCast(o, TcpClient)
Dim s As IO.Stream = tc.GetStream
Dim tr As New IO.StreamReader(s, System.Text.Encoding.ASCII)
Dim tw As New IO.StreamWriter(s, System.Text.Encoding.ASCII)
tw.AutoFlush = True
Do
Dim l As String = tr.ReadLine()
If l = "" Then
Exit Do
End If
Console.WriteLine(l)
tw.WriteLine("Received " & l)
Loop

tr.Close()
tw.Close()
s.Close()

End Sub

Nov 20 '05 #2

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

Similar topics

7
by: Gabriele Farina | last post by:
Hi, I'd like to manage multiple socket connection without having to use Threads. I'd like to manage every connection when it is returned from socket_Accept(), without having to wait for the...
2
by: Paul A. Steckler | last post by:
I need to write a TCP/IP server in C# that can handle multiple connections. My first try was to use TCPListener instances in multiple .NET threads. Of course, I got an exception from...
2
by: jasonsgeiger | last post by:
From: "Factor" <jasonsgeiger@gmail.com> Newsgroups: microsoft.public.in.csharp Subject: Multiple Clients, One port Date: Wed, 19 Apr 2006 09:36:02 -0700 I'm been working with sockets for a...
2
by: apollo135 | last post by:
Dear All, Could someone help and tell me how to handle multiple send and receive operations with udp sockets? In fact here is my problem: server.c is composing of serveral sub programs (the...
3
by: dynamo08 | last post by:
Hi, I am new to socket programming, I wrote an ftpclient which connects to an ftp server and downloads a file to the client computer. Now in one client connection I want to download multiple files...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.