Click here to Skip to main content
15,886,919 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionOpenGL with VB .NET Pin
Forgon22-Jun-09 14:17
Forgon22-Jun-09 14:17 
AnswerRe: OpenGL with VB .NET Pin
Eslam Afifi22-Jun-09 14:55
Eslam Afifi22-Jun-09 14:55 
QuestionWith clouse Pin
Bahram.Zarrin22-Jun-09 11:02
Bahram.Zarrin22-Jun-09 11:02 
AnswerRe: With clouse Pin
Christian Graus22-Jun-09 11:05
protectorChristian Graus22-Jun-09 11:05 
GeneralRe: With clouse Pin
EliottA22-Jun-09 11:11
EliottA22-Jun-09 11:11 
GeneralRe: With clouse Pin
Dalek Dave22-Jun-09 23:54
professionalDalek Dave22-Jun-09 23:54 
GeneralRe: With clouse Pin
dan!sh 23-Jun-09 2:53
professional dan!sh 23-Jun-09 2:53 
QuestionWinsock 2005 Problem Pin
morpheusv622-Jun-09 6:48
morpheusv622-Jun-09 6:48 
Hi,

I am trying to make a client server form application using VB2005. I am using VS2005 Professional for development.

The problem is as follows:

When more than one client tries to connect to the server. The connection is refused and the Client gets an exception in Connect() method - Target machine actively refused the connection.

This problem occurs only when 2 or more clients try to simultaneously connect to the server. For a single client accessing at a time the problem does not occur.

The code segment is as given below:

-----------1 Module
Imports System.Net.Sockets
Imports System.Net
Public Class FrmMdiParent

   Dim WithEvents wsServer As New Winsock2005DLL.Winsock

   Private Sub FrmMdiParent_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
      If wsServer.State = Winsock2005DLL.WinsockStates.Connected Then wsServer.Close()
   End Sub

   Private Sub FrmMdiParent_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      main()
      Try
                  wsServer.MaxPendingConnections = 20
                  wsServer.LocalPort = 8000
         wsServer.Listen()

      Catch ex As Exception
         MessageBox.Show(ex.Message, "Exceptions Handler!", MessageBoxButtons.OK, MessageBoxIcon.Error)
      End Try
   End Sub
  
   Private Sub wsServer_ConnectionRequest(ByVal sender As Object, ByVal e As Winsock2005DLL.WinsockClientReceivedEventArgs) Handles wsServer.ConnectionRequest
            If wsServer.State = Winsock2005DLL.WinsockStates.Connected Then
            MessageBox.Show("Server is busy with other clients.", "Server connection failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End If
            wsServer.Accept(e.Client)
      End Sub

   Private Sub wsServer_DataArrival(ByVal sender As Object, ByVal e As Winsock2005DLL.WinsockDataArrivalEventArgs) Handles wsServer.DataArrival
      Try

         Dim str As String = ""
                  wsServer.Get(str)
         .........(other statements)
         End Select
      Catch ex As Exception
         MessageBox.Show(ex.Message, "Exceptions handler!", MessageBoxButtons.OK, MessageBoxIcon.Error)
      End Try
   End Sub

   Private Sub wsServer_Disconnected(ByVal sender As Object, ByVal e As System.EventArgs) Handles wsServer.Disconnected
      wsServer.Listen()
   End Sub

   Private Sub mnuItmLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuItmLogin.Click
      Select Case mnuItmLogin.Tag
         Case 0
            ' Login
            Dim objfrmlogin As New FrmLogin
            objfrmlogin.ShowDialog()

         Case 1

            ' Logout
            mnuSvrAuth.Enabled = False
            mnuItmLogin.Tag = 0
            mnuItmLogin.Text = "&Login"
      End Select
   End Sub

End Class

----------------2 Module

Dim WithEvents winSock1 As New Winsock2005DLL.Winsock

#Region " WinSock events "

#Region " Connected "

      Private Sub winSock1_Connected(ByVal sender As Object, ByVal e As System.EventArgs) Handles winSock1.Connected

            If isRequest Then

               .................

      End Sub

#End Region

#Region " Data Arrival "

      Private Sub winSock1_DataArrival1(ByVal sender As Object, ByVal e As Winsock2005DLL.WinsockDataArrivalEventArgs) Handles winSock1.DataArrival
            Dim str As String = ""
            winSock1.Get(str)

         .................

      End Sub

#End Region

#Region " Error Occured "

      Private Sub winSock1_ErrorReceived(ByVal sender As Object, ByVal e As Winsock2005DLL.WinsockErrorEventArgs) Handles winSock1.ErrorReceived
            MessageBox.Show(e.Message, "Error Occured from server.", MessageBoxButtons.OK, MessageBoxIcon.Error)
      End Sub

#End Region

-----------------

The above exception is thrown when more than 1 clients try to access the server simultaneously.

I am not able to find any solution to this problem, any help will be really useful.

Thanks

-Dev
AnswerRe: Winsock 2005 Problem Pin
Dave Kreskowiak23-Jun-09 5:43
mveDave Kreskowiak23-Jun-09 5:43 
QuestionReference Equivelants in .net Pin
No-e22-Jun-09 5:56
No-e22-Jun-09 5:56 
AnswerRe: Reference Equivelants in .net Pin
Henry Minute22-Jun-09 6:32
Henry Minute22-Jun-09 6:32 
QuestionHTML Help Index Problem Pin
rdculver22-Jun-09 4:14
rdculver22-Jun-09 4:14 
AnswerRe: HTML Help Index Problem Pin
rdculver29-Jun-09 4:34
rdculver29-Jun-09 4:34 
QuestionHow to code for design window Pin
Member 300692622-Jun-09 2:21
Member 300692622-Jun-09 2:21 
AnswerRe: How to code for design window Pin
EliottA22-Jun-09 2:31
EliottA22-Jun-09 2:31 
AnswerRe: How to code for design window Pin
Henry Minute22-Jun-09 4:12
Henry Minute22-Jun-09 4:12 
Questionget text from html format Pin
rmedo21-Jun-09 23:25
rmedo21-Jun-09 23:25 
AnswerRe: get text from html format Pin
Christian Graus21-Jun-09 23:55
protectorChristian Graus21-Jun-09 23:55 
GeneralRe: get text from html format Pin
rmedo21-Jun-09 23:57
rmedo21-Jun-09 23:57 
GeneralRe: get text from html format Pin
Christian Graus22-Jun-09 0:01
protectorChristian Graus22-Jun-09 0:01 
QuestionXP panel [modified] Pin
mirzamujib21-Jun-09 21:43
mirzamujib21-Jun-09 21:43 
AnswerRe: XP panel Pin
Henry Minute22-Jun-09 1:20
Henry Minute22-Jun-09 1:20 
GeneralRe: XP panel [modified] Pin
mirzamujib22-Jun-09 1:39
mirzamujib22-Jun-09 1:39 
GeneralRe: XP panel Pin
Henry Minute22-Jun-09 1:56
Henry Minute22-Jun-09 1:56 
GeneralRe: XP panel Pin
mirzamujib22-Jun-09 3:31
mirzamujib22-Jun-09 3:31 

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.