Click here to Skip to main content
16,006,373 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Creare report Word in C# .NET 2005 Pin
Pete O'Hanlon16-Nov-09 9:37
mvePete O'Hanlon16-Nov-09 9:37 
AnswerRe: Creare report Word in C# .NET 2005 Pin
Luc Pattyn16-Nov-09 9:54
sitebuilderLuc Pattyn16-Nov-09 9:54 
AnswerRe: Creare report Word in C# .NET 2005 Pin
dv377317-Nov-09 3:08
dv377317-Nov-09 3:08 
GeneralRe: Creare report Word in C# .NET 2005 Pin
dv377317-Nov-09 13:31
dv377317-Nov-09 13:31 
QuestionWhat is F# Pin
anishkannan16-Nov-09 1:07
anishkannan16-Nov-09 1:07 
AnswerRe: What is F# Pin
Simon P Stevens16-Nov-09 1:39
Simon P Stevens16-Nov-09 1:39 
AnswerRe: What is F# Pin
salkad200716-Nov-09 2:42
salkad200716-Nov-09 2:42 
Questionsimultaneous multiple socket connexions Pin
Crisleelee16-Nov-09 0:06
Crisleelee16-Nov-09 0:06 
Hello!

I'm building an application for communication with several devices (not PCs) over Network, using both TCP and UDP protocols.

For this I need two kinds of connexions:
- a connexion (one at the time) with the targeted device, initiated only for parameters setting and device servicing purposes;
- simultaneous multiple connexions with several devices for collecting data (by polling devices).

First one was solved using asynchronous sockets methods, and a timer to periodically check connection status and some other relevant parameters.
See below the basic code for initiating connexion:
'Initialize Socket
Private testSocket As Socket
'Open connexion
Public Sub OpenConnexion(ByVal addressIP As String, ByVal portNo As String, ByVal IPportType As String)
    Dim remoteIP As IPAddress = IPAddress.Parse(addressIP)
    Dim remotePort As Int32 = CInt(portNo)
    If IPportType = "TCP" Then
        testSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
        testSocket.BeginConnect(remoteIP, remotePort, AddressOf CheckConnection, Nothing)
    ElseIf IPportType = "UDP" Then
        testSocket = New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
        testSocket.BeginConnect(remoteIP, remotePort, AddressOf CheckConnection, Nothing)
    End If
End Sub
'Connexion result event
Public Sub CheckConnection(ByVal ar As IAsyncResult)
    Try
        testSocket.EndConnect(ar)
        'CallDeviceConnected()
    Catch ex As Exception
        'CallDeviceDisconnected()
    End Try
End Sub

For the second one, using the the same way by simply repeating the code and manually indexing each Sub, the code will become rapidly too large, too complicated and not productive at all.
I've tried a different approach building an Array of Sockets but then I encountered another issue: how to pass the connexion index to connexion result, in order to determine which connexion is active or not.
See below the attempt of code:
'Maximum no. of simultaneous connections
Private maxConnexions As Int32 = 10
'Initialize Socket
Private testSocketArr(maxConnexions) As Socket
'Open connexion
Public Sub OpenConnexionArr(ByVal index As Int32, ByVal addressIP As String, ByVal portNo As String, ByVal IPportType As String)
    Dim remoteIP As IPAddress = IPAddress.Parse(addressIP)
    Dim remotePort As Int32 = CInt(portNo)
    If IPportType = "TCP" Then
        testSocketArr(index) = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
        testSocketArr(index).BeginConnect(remoteIP, remotePort, AddressOf CheckConnectionArr, index)
    ElseIf IPportType = "UDP" Then
        testSocketArr(index) = New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
        testSocketArr(index).BeginConnect(remoteIP, remotePort, AddressOf CheckConnectionArr, index)
    End If
End Sub

I have found on Web a lot of examples about dealing with multiple connexions or building a server which can manage hundreds of clients. What I need is a kind of reverse job: to build a client which connects to multiple servers and then poll each of them.

Please help me with some ideas for putting this application on the right track.
Thanks!

Cristian
QuestionFramework Dependancy Pin
Gjm15-Nov-09 13:00
Gjm15-Nov-09 13:00 
AnswerRe: Framework Dependancy [modified] Pin
Luc Pattyn15-Nov-09 13:43
sitebuilderLuc Pattyn15-Nov-09 13:43 
AnswerRe: Framework Dependancy Pin
freakyit15-Nov-09 23:58
freakyit15-Nov-09 23:58 
AnswerRe: Framework Dependancy Pin
Shameel16-Nov-09 4:47
professionalShameel16-Nov-09 4:47 
AnswerRe: Framework Dependancy Pin
Dave Kreskowiak16-Nov-09 6:28
mveDave Kreskowiak16-Nov-09 6:28 
QuestionHow can I use 'ApplyPropertyChanges()' to update the entity's navigation properties? Pin
chriskwok@live.cn14-Nov-09 18:48
chriskwok@live.cn14-Nov-09 18:48 
AnswerRe: How can I use 'ApplyPropertyChanges()' to update the entity's navigation properties? Pin
The Man from U.N.C.L.E.15-Nov-09 22:54
The Man from U.N.C.L.E.15-Nov-09 22:54 
GeneralRe: How can I use 'ApplyPropertyChanges()' to update the entity's navigation properties? [modified] Pin
Not Active16-Nov-09 1:08
mentorNot Active16-Nov-09 1:08 
GeneralRe: How can I use 'ApplyPropertyChanges()' to update the entity's navigation properties? [modified] Pin
chriskwok@live.cn16-Nov-09 3:44
chriskwok@live.cn16-Nov-09 3:44 
GeneralRe: How can I use 'ApplyPropertyChanges()' to update the entity's navigation properties? [modified] Pin
Not Active16-Nov-09 3:59
mentorNot Active16-Nov-09 3:59 
AnswerRe: How can I use 'ApplyPropertyChanges()' to update the entity's navigation properties? Pin
Not Active16-Nov-09 1:37
mentorNot Active16-Nov-09 1:37 
QuestionHow to Export data from SQL Server to Excel Pin
zizigolo11013-Nov-09 16:53
zizigolo11013-Nov-09 16:53 
AnswerRe: How to Export data from SQL Server to Excel Pin
kstls14-Nov-09 0:17
kstls14-Nov-09 0:17 
AnswerRe: How to Export data from SQL Server to Excel Pin
computerhussain15-Nov-09 19:54
computerhussain15-Nov-09 19:54 
QuestionProblem with items for listview . if can't ,say me please [modified] Pin
darkyro13-Nov-09 11:51
darkyro13-Nov-09 11:51 
AnswerRe: Problem with items for listview . if can't ,say me please Pin
Luc Pattyn13-Nov-09 11:58
sitebuilderLuc Pattyn13-Nov-09 11:58 
GeneralRe: Problem with items for listview . if can't ,say me please Pin
darkyro13-Nov-09 12:08
darkyro13-Nov-09 12:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.