Bug #18721 Socket Error
Submitted: 3 Apr 2006 1:30 Modified: 4 Apr 2006 22:25
Reporter: Steve Ling Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:1.0.7.30072 OS:.NET & MySQL Linux
Assigned to: CPU Architecture:Any

[3 Apr 2006 1:30] Steve Ling
Description:
Using VB.NET 2003

Hello,

I can use the 3.51 ODBC driver to connect to all of the databases mentioned below to the Linux/MySQL without any issues.

Tried on the following versions of MySQL linux
Server version 4.0.25-standard
Server version 4.1.7
Server version 4.1.18

With the connector/net I cannot even open the connection to the database I get the following:

First Error:
An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in system.dll

Additional information: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full

Second Error:
An unhandled exception of type 'System.TypeInitializationException' occurred in system.dll

Additional information: The type initializer for "System.Net.Sockets.Socket" threw an exception.

Final Error:
MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts ---> System.TypeInitializationException: The type initializer for "System.Net.Dns" threw an exception. ---> System.TypeInitializationException: The type initializer for "System.Net.Sockets.Socket" threw an exception. ---> System.Net.Sockets.SocketException: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full

   at System.Net.Sockets.Socket.InitializeSockets()

   at System.Net.Sockets.Socket..cctor()

   --- End of inner exception stack trace ---

   at System.Net.Sockets.Socket.InitializeSockets()

   at System.Net.Dns..cctor()

   --- End of inner exception stack trace ---

   at System.Net.Dns.GetHostByName(String hostName)

   at MySql.Data.Common.StreamCreator.GetStream(Int32 timeOut)

   at MySql.Data.MySqlClient.NativeDriver.Open()

   --- End of inner exception stack trace ---

   at MySql.Data.MySqlClient.NativeDriver.Open()

   at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionString settings)

   at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()

   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()

   at MySql.Data.MySqlClient.MySqlPool.GetConnection()

   at MySql.Data.MySqlClient.MySqlPoolManager.GetConnection(MySqlConnectionString settings)

   at MySql.Data.MySqlClient.MySqlConnection.Open()

   at EspToolsVB.frmMainMenu.MainMenu_Load(Object sender, EventArgs e) in C:\Documents and Settings\stevel\My Documents\Visual Studio Projects\KiwiToolsV1.0.0\EspToolsVB\frmMainMenu.vb:line 594

How to repeat:
This does work:

Imports System.Data.Odbc

Public ODBCConn As OdbcConnection

ODBCConn = New OdbcConnection

ODBCConn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & _
                                           "Server=" & DBServer & ";" & _
                                           "Port=" & DBPort & ";" & _
                                           "Option=3;" & _
                                           "Stmt=;" & _
                                           "Database=" & DBName & ";" & _
                                           "Uid=" & DBLogin & ";" & _
                                           "Pwd=" & DBPassword & ""

ODBCConn.Open()

This does not work:

Imports MySql.Data.MySqlClient

Public MySQLConn As MySqlConnection

MySQLConn = New MySqlConnection

MySQLConn.ConnectionString = "server=" & DBServer & ";" & _
                                        "uid=" & DBLogin & ";" & _
                                        "pwd=" & DBPassword & ";" & _
                                        "database=" & DBName & ";"

'Here is where I get the error
MySQLConn.Open()
[4 Apr 2006 22:25] Steve Ling
If using VS.NET 2003 and have Framework 1.1 installed you have to install Framework 1.1 SP1 or you will recieve socket errors and cause DNS to resolve the Ip address or the hostname incorrectly of the server you are connecting to.