VS 2010 : How To Use Socket

Mar 22, 2012

i can connect socket well but i want to ask how can i determine that socket has received data i want to create sub or function that handles socket.receive byte the code i have is

Dim byteData(100) As Byte
Dim size As Integer = soc.Receive(byteData) 'receiving the data from socket and reading its size
For i As Integer = 0 To size
Console.Write(Convert.ToChar(byteData(i))) 'Convert.ToChar will convert the byte value into character
Next

i want to start this code each time when socket receives something?

View 1 Replies


ADVERTISEMENT

Identify Connection Lost Between Socket Server And Socket Client?

May 21, 2011

I wrote a Socket Client which will send the Socket Server some data and get some response from Server. This process will be running once in every 2 seconds.

Now what I need to know is How we can identify the connection lost between Server and Client?

I need this to be implemented in the Client side. If there is no connection then Client should automatically close the connection. Once the connection with the server is available in the next attempt it should connect automatically.

View 1 Replies

VS 2010 Socket And TCPClient ?

Jun 8, 2012

I am making a contact management program that works like a chat conversation. First, the client connects with his/her name and says: GIVE_INFO. Then, the server sends the client's info that it gets from a csv. Finally, when the user makes all desired changes, the client "tells" the server the info separated by commas and the server replaces the information in the old csv with the new info.So, the program worked for 2-3 times then all of a sudden when I made some changes it stopped working[code].......

View 2 Replies

VS 2010 Socket Using FTP Stream?

Jan 29, 2012

I am successfuly connecting to an FTP server and have no problems with uploading / downloading files and initiating general file transfers. However, when attempting to list the directory I get a strange exception and it seemed to just start happening of its own accord.

Cannot access a disposed object. Object name: 'System.Net.Sockets.NetworkStream'. This is confusing! I am certainly not manually disposing any of the connection of stream reader objects, nor am I disposing anything else in this entire sub routine. On setting breakpoints, it seems that the array list is filled correctly but then the error fires when the status code is 226 despite me clearly specifying that the while loop should not run under these circumstances. (226 is equal to FtpStatusCode.ClosingData)

View 6 Replies

VS 2010 IRC Server - Socket System

Aug 3, 2011

i'm creating an IRC server and I already have a few base classes complete like logging and Config. I was about to start with programming the socket class(es) when I realized that I have no idea how to make such a complicated socket system. I do not under any circumstance want to use any other code than my own since that would not help me learn sockets. I am familiar with a single connection socket system like most tutorials use.

[Code]...

View 2 Replies

VS 2010 Socket Connect Timeout?

Oct 2, 2011

i need to check if a port is open, apparently i can't ping ports so i need to use sockets, and it seems that there is no option for timeout on the connecting... how can i put a timeout on connect?

View 3 Replies

Converting Socket Connection From Python To VB 2010?

Mar 23, 2012

I have codes which is written with python. I am not good with python and i want to convert this python codes to VB 2010.This python function searching local network and finding my LG TV's local IP adress. I want to find my TV's local IP with VB 2010.

[Code]...

View 9 Replies

VS 2010 - Speed: WebClient Versus Socket

Apr 25, 2012

I make a lot of programs that require an internet connection to download things from the web.At the very beginning, I used WebClient, as I didn't know Socket & how it worked.But now, I use Socket all the time, altough it's more lines of code. It seems to work faster then WebClient.I am interested if this is really true & why WebClient is slower (so is HttpWebRequest) then just a Socket.I've setup 2 threads which starts on the click of a button (WebClient thread starts first), the Socket beats the WebClient by just some milliseconds, but still.Each way has it's advantages & disadvantages, e.g.: if you use Socket, you need to write the header yourself & parse the response header.My question is, which one do you prefer & why ?Do you know why WebClient & HttpWebRequest are slower then Socket, as I assume, WebClient & HttpWebRequest both use tcp to download the things.

View 2 Replies

VS 2010 Handle Receive Data On A Socket?

Sep 3, 2010

I've looked through a lot of snippets online and I see a lot of things similar to

Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

but what I am unsure of when to call such a thing? How do I know when there is data to receive...in visual basic 6 with winsock, there was a specific routine which was called upon data arrival, but I see nothing of the sort for vbNet.

View 2 Replies

VS 2010 Socket Chat Is Not Receiving On Java Server

Aug 17, 2011

I am making a java chat server, and a guy was able to connect to it no problem (however, he logged off for the night before I ran into any problems, so I couldn't see what he did). Here is my code on the VB form:

[Code]....

View 5 Replies

Client Socket - Send Message Through Client Socket Receive Specified Argument Was Out Of Range Of Valid Values

Oct 15, 2011

Below is my code, but when i send the message thru client socket i receive Specified argument was out of the range of valid values. Parameter name: size

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim serverStream As NetworkStream = clientSocket.GetStream()
Dim outStream As Byte() = _
System.Text.Encoding.ASCII.GetBytes("0800822000000000000004000000000000000920092126012345001")

[CODE]...

View 1 Replies

VS 2010 TCP Chat Server Closes Socket On Client DisConnect?

Jun 24, 2010

I am working on a chat client and server, and so far it works well, but when I close the client, the server throws an exception because it continues to try to do processes on the disconnected client. I have tried adding clientSocket.Close() in various places throughout the client and server with no luck. Does someone know how to add the disconnect code to either the server or client with this code?Server:

Imports System.Net.Sockets
Imports System.Text
Module Module1

[code].....

View 5 Replies

C# - Set Up A Web Socket Connection In .NET

Jun 22, 2011

I have my index.aspx file:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb" Inherits="Web_Socket.index" %>
<!DOCTYPE html>
<html>

[Code]....

so now my question is how do i connect the WebSocketServer.cs to the index.aspx ?

As a start, all I'm trying to accomplish is just to get the Web Sockets working, and have the connection established, which then will alert("Stock Ticker Connection open ...");

View 1 Replies

Keep A Socket Declared?

Apr 9, 2011

how do I keep a Socket declared forever so i can call it in other methods?

All the tutorials i've read just have a server, client, server sends client message, client disconnects. What if I want to remain connected? I've tried making the sockets global but that didn't work somehow.

View 1 Replies

Re-use Socket (UDP) With Another Port?

Apr 17, 2008

I have a socket which I use to monitor data on a specific UPD port (Let's say 1200).[code]...

View 3 Replies

Socket Won't Stick?

Apr 9, 2011

Then I ran into problem #1 - I wanted to call the methods in another sub but they were shared so I received the error:"Cannot refer to an instance member of a class from within a shared method without an explicit instance of a class"o, I took out shared since I didn't know how to fix it, and put in the Following as Global Variables:

Public listener As System.Net.Sockets.Socket
Public handler As System.Net.Sockets.Socket
Public client As System.Net.Sockets.Socket

[code].....

View 1 Replies

Asynchronous Socket Programming?

Feb 23, 2010

i'm creating an Asynchronous socket programming in vb.net. i've utilised the code from Asynchronous client and server code frtom the following links:m a new user so could post only one link fully)When I try to connect the for more than one client the second client always waits until the first clientcompletes the call. i want the clients to accept calls at the same time

View 1 Replies

C# - When To Call BeginAccept On A Socket

Nov 26, 2010

I have the following class in a Windows Service that is experiencing some vary strange shutdown behaviors. The server is shutting down from time-to-time with only this message in the event logs and no messages in the trace logs, "The Broadcaster service terminated unexpectedly. It has done this 1 time(s)."

[Code]...

View 2 Replies

Closing Socket Each Time?

May 5, 2009

In my small P2P Chat application I am listening on a port for messages and if some message arrives and pending, I am accepting it to a TcpClient and reading the data from the stream, writing back a "Received" response and closing it. This is in a loop with a sleep interval of 500 secs and runs in a separate thread. Is it a good practice to close the socket each time I receive and process a message or should I keep it alive till the chat box is closed on other side?

I am asking this because, when I do a "NETSTAT" on command line while chatting with someone, there is one entry per message that arrives locally. and many ports get to TIME_WAIT status, even if it is understood that they will be removed after 2 mins by the system.

View 3 Replies

Communications :: Socket Raw And Vista II ?

Aug 7, 2009

Using the Socket raw, with XP I can read without problems both the incoming packets and the outgoing packets. With Vista (I have tried also others Sniffers) is impossible to see the outgoing packets...WHY? what I have to do to see alse the outgoing packets? In reality I have not to read packet data or packet lenght... I need only to count the number of incoming packets and outgoing packets... but with Vista this job seems impossible... or not?

View 1 Replies

Converting Socket Written In PHP?

Sep 21, 2011

I want to access a socket that has been opened for me by my service providers. Their socket is written in PHP and I don't understand PHP at all. Themselves they don't understand VB.Net

The Code in PHP as as below

<?
$num = $_GET['num'];
$ext = $_GET['ext'];

[Code].....

View 2 Replies

Create Socket In Runtime

Nov 22, 2011

how to create tcp socket in runtime. suppose i want to create a 1 to 100 array of a socket and sending data by it how can i do it

View 1 Replies

Data Receiving With Socket?

Sep 27, 2011

i am working on 3rd party chat software, when ever i send data to server i get incorrect buffersize of data. like when i convert that data to hex to matching header for splitting data i got huge lengths data

in the above textbox of image i have got some 0000000000000000000.... with the hex data, how can i get only only original data. The code i have used to receive data is

[Code]...

View 1 Replies

Document About Socket Or Network?

Oct 18, 2009

I am into minds about how can i learn about programming soket or network.I want to you give me a website guid me about that.

View 2 Replies

Error When Working With Socket TCP IP

Jan 12, 2011

this is the first time I try to study the socket of .NET. I configed follow the tutorial here [URL] . Then I try to write some execute code for my project. I insert an "Add item" to a listbox after socket server receiving Data from client. However, the server doesn't execute my "Add item" code and it disconnect to the client? If I erase this code, everything is ok!

[Code]...

View 6 Replies

Getting A Console Based Socket App?

Aug 3, 2009

i have made a console based socket program in vb.net, all it does 2 things:

1- server shows a msgbox when the command msg is sent from the client

2- the server opens the cd try when the command open is sent form the client

when i run it , i type the command open and works just fine , the cd tray opens , but if i type open again or msg it simply wont do anything(this also applies for the command msg, if type it a msg is shown, but if i type it agine or open , it wont respond. so its like one command per session. i tried to put the code in a while loop , but didnt work?

here is the code for the server:

Imports System.IO
Imports System.Net.Sockets
Module Module1

[code]....

View 2 Replies

How To Make Socket Chat

Jan 19, 2010

There are a series of web requests, database handling using php as well as using mysql connector. There are at most 5 timers in one window. some window has 3 or 2 timers as needed.Among some features there is a feature for chat. and I'm doing it with Remote mysql connection using mysql data connector.I'm not much familiar with VB.NET coding environment as well as with optimization issues. However made that app running with some problem, that is, when chatting, sometimes its not working smoothly sometimes stops for 4-5 secs then again responding. I'm not sure if this is happening because of timers. However a chat window has 2 timers of 1sec each.

View 2 Replies

How To Separate TCP Socket Messages

Dec 5, 2010

I've experimented a bit with async TCP socket messages between two programs, for passing data, numbers and/or text. What I've done is to use a keyword in the start of each message,and then seperate the values with the "|" character. So a message may look like this: "DATA|490|40517.9328222222|1|6|11345|11347|11344|11345|106|40517.8494212963"I set the read buffer size to 1024, as most of the messages will be within that lengthHowever sometimes I may send rapidly many short messages where several together are less than 1024 characters, and it seems then it will be read in one go. And if I send a message longer than 1024 characters, it will be split. So I'm looking for some advice on how to handle this. Should I use some special characters to start and/or end each message?

View 6 Replies

Multiple Socket Connections?

Nov 14, 2010

OK here is some code I nicked from web and I have changed some things, it works but only accepting one client, how do I make this accept multiple clients?

[Code]...

View 2 Replies

Send Data With Socket?

Feb 21, 2011

I want to connect with a barcode printer and sendhim some specific characters and take back anything they send to me

[code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved