Click here to Skip to main content
15,893,564 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionImport Data From Oracle *.DMP File to SQL Server Pin
Nadeem Akhter7-Nov-05 16:02
Nadeem Akhter7-Nov-05 16:02 
QuestionPrinter status is Unknown Pin
VanitaJ7-Nov-05 12:55
VanitaJ7-Nov-05 12:55 
AnswerRe: Printer status is Unknown Pin
VanitaJ8-Nov-05 5:55
VanitaJ8-Nov-05 5:55 
GeneralRe: Printer status is Unknown Pin
Dave Kreskowiak8-Nov-05 10:04
mveDave Kreskowiak8-Nov-05 10:04 
GeneralRe: Printer status is Unknown Pin
VanitaJ8-Nov-05 12:48
VanitaJ8-Nov-05 12:48 
GeneralRe: Printer status is Unknown Pin
Dave Kreskowiak9-Nov-05 4:23
mveDave Kreskowiak9-Nov-05 4:23 
GeneralRe: Printer status is Unknown Pin
KaptinKrunch8-Nov-05 10:54
KaptinKrunch8-Nov-05 10:54 
QuestionTCP Client Pin
Brent Lamborn7-Nov-05 10:28
Brent Lamborn7-Nov-05 10:28 
Hello...

I'm new to network programming and am trying to create a simple application that will allow me to send test TCP messages to a listening windows service. Here is my send function:

<br />
    Function Send(ByVal message As String) As String<br />
        Dim stream As NetworkStream = Nothing<br />
        Dim responseData As String = ""<br />
        Dim localEP As New IPEndPoint(IPAddress.Parse("127.0.0.1"), 11000)<br />
<br />
        Try<br />
<br />
            ' Instantiate a TcpClient with the target server and port number<br />
            Dim client As New TcpClient(localEP)<br />
<br />
            ' Convert the data to send into a byte array<br />
            Dim data As Byte() = System.Text.Encoding.ASCII.GetBytes(message)<br />
<br />
            ' Get the NetworkStream for the TcpClient for sending and receiving<br />
            stream = client.GetStream()<br />
<br />
            ' Send the message to the server. <br />
            stream.Write(data, 0, data.Length)<br />
<br />
            ' Buffer to hold data returned from the server.<br />
            data = New [Byte](256) {}<br />
<br />
            ' Read the response from the server up to the size of the buffer.<br />
            Dim bytes As Integer = stream.Read(data, 0, data.Length)<br />
<br />
            ' Convert the received bytes into a string<br />
            responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)<br />
<br />
        Catch ex As SocketException<br />
            MsgBox(ex.Message)<br />
        Catch ex As IOException<br />
            MsgBox(ex.Message)<br />
        Finally<br />
<br />
            ' Make sure that the NetworkStream is closed.<br />
            If stream IsNot Nothing Then<br />
                stream.Close()<br />
            End If<br />
<br />
        End Try<br />
<br />
        Return responseData<br />
    End Function<br />
<br />


The line of code as follows...stream = client.GetStream() causes this InvalidOperationException:

The operation is not allowed on non-connected sockets.

I'm using VS 2005 Beta 2 (.NET 2.0). I have no idea what the problem is. Any ideas?

Thanks in advance!

"Half this game is ninety percent mental."
- Yogi Berra
AnswerRe: TCP Client Pin
capitan_cavernicola13-Jan-06 0:01
capitan_cavernicola13-Jan-06 0:01 
QuestionMicrosoft Web Browser Control Pin
Mo_developer7-Nov-05 5:48
Mo_developer7-Nov-05 5:48 
AnswerRe: Microsoft Web Browser Control Pin
Brent Lamborn7-Nov-05 12:29
Brent Lamborn7-Nov-05 12:29 
QuestionMultiple comboboxes in datagrid.... Pin
oakleaf7-Nov-05 5:26
oakleaf7-Nov-05 5:26 
AnswerRe: Multiple comboboxes in datagrid.... Pin
rudy.net9-Nov-05 17:55
rudy.net9-Nov-05 17:55 
QuestionSequential Structures with arrays Pin
rand197-Nov-05 4:48
rand197-Nov-05 4:48 
AnswerRe: Sequential Structures with arrays Pin
Joshua Quick7-Nov-05 7:06
Joshua Quick7-Nov-05 7:06 
GeneralRe: Sequential Structures with arrays Pin
rand197-Nov-05 7:29
rand197-Nov-05 7:29 
GeneralRe: Sequential Structures with arrays Pin
Joshua Quick7-Nov-05 7:43
Joshua Quick7-Nov-05 7:43 
GeneralRe: Sequential Structures with arrays Pin
rand197-Nov-05 8:19
rand197-Nov-05 8:19 
GeneralRe: Sequential Structures with arrays Pin
Joshua Quick7-Nov-05 9:09
Joshua Quick7-Nov-05 9:09 
QuestionAdding reference at runtime Pin
nikneem20057-Nov-05 2:12
nikneem20057-Nov-05 2:12 
AnswerRe: Adding reference at runtime Pin
S. Senthil Kumar7-Nov-05 3:59
S. Senthil Kumar7-Nov-05 3:59 
AnswerRe: Adding reference at runtime Pin
Steve Pullan8-Nov-05 11:33
Steve Pullan8-Nov-05 11:33 
Questionmultiple selection on a dropdownlist Pin
mcgann7-Nov-05 2:10
mcgann7-Nov-05 2:10 
AnswerRe: multiple selection on a dropdownlist Pin
rudy.net9-Nov-05 18:03
rudy.net9-Nov-05 18:03 
Questionhelp pls , doubt with collection class in vb Pin
tejaswi-teja7-Nov-05 2:06
tejaswi-teja7-Nov-05 2:06 

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.