473,385 Members | 1,753 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,385 software developers and data experts.

Problems with Receiving info over Sockets

Purpose of Program: I want to create a simple program that logs into a
device gets some info and stores that info elsewhere. I just wanted to
see if I could connect and receive the banner that comes up. Currently
the program is in a barebones form.

Problem: I can get connected just fine but I cannot receive the banner
when it comes up. I even added a loop that waits until there are bytes
available before it tries to read. But even when there are bytes
available to read, there is nothing in the buffer to receive.

Any suggestions would be greatly appreciated.

' Data buffer for incoming data.
Dim bytes(2048) As Byte
Dim bytesRec As Integer

' Connect to a remote device.
' Establish the remote endpoint for the socket.
Dim ipAddress As IPAddress = ipAddress.Parse("10.194.177.6")
Dim remoteEP As New IPEndPoint(ipAddress, 23)

' Create a TCP/IP socket.
s = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)

' Connect the socket to the remote endpoint.
s.Connect(remoteEP)

' Clear out the bytes buffer
bytes = Encoding.ASCII.GetBytes("")

TextBox1.Text = "Socket connected to " & s.RemoteEndPoint.ToString() &
vbCrLf

' Wait until there is something in the devices buffer before try to
read
Do
TextBox1.Text = TextBox1.Text & s.Available.ToString & vbCrLf
Loop Until s.Available.ToString <> 0 Or s.Connected = False

bytesRec = s.Receive(bytes)
TextBox1.Text = TextBox1.Text & "Echoed test = " &
Encoding.ASCII.GetString(bytes, 0, bytesRec) & " - BytesRec: " &
bytesRec & vbCrLf

'release the socket
s.Shutdown(SocketShutdown.Both)
s.Close()

Apr 28 '06 #1
0 812

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

Similar topics

4
by: Stephan Steiner | last post by:
Hi I'm having some weird threading issues.. almost at random, if I dare change a line of my code, the shutdown sequence gets messed up. I'm using a thread to receive data from the network, that...
1
by: Amadej | last post by:
Hello everyone, I'm having some odd problems with a little program I wrote for sending/receiving bytes across the network. I am using synchronous sockets, and it seems that when I send byte...
0
by: André Betz | last post by:
Hi, I've established a TCP-Socket Connection and now I want to receive datas. So I called BeginReceive where I set the receiving buffer and length. Now in the asynchronous CallBack-Function I...
10
by: Alejandro Castañaza | last post by:
Hi. I'm writing a program, and I need to send confidential data through the network, so I decided to use encryption, using the System.Security.Cryptography namespace. I'm using the sockets...
0
by: ZR | last post by:
I am writing two applications which needs to (among other things) communicate through network, so one of them is a client and the other one is a server. I have used asynchronous socket examples...
11
by: Tor Erik | last post by:
Hi, The reason is that my application does about 16 connects and data transfers per second, to the same 16 remote hosts. After approx 200 secs there are 4000 sockets waiting to be garbage...
6
by: White Spirit | last post by:
I have the following code to send a packet to a remote socket and receive a response in return: System.Net.Sockets.Socket locSocket = new System.Net.Sockets.Socket (AddressFamily.InterNetwork,...
0
by: pecka | last post by:
Hello. I have an application written in C# framework 1.1. Im using the System.Net.Sockets namespace. I've been using code from...
0
by: george585 | last post by:
Hello! I am new to network programming, and understand just basics. Using some sample code, and having read documentation, I managed to create a simple app in C# and VB.NET. The application is...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.