|
-
Mar 7th, 2004, 03:39 AM
#1
Thread Starter
Frenzied Member
Delegates *Given Up*
I have Two classes that I am porting from C#, SocketClient and SocketServer both Delegate Declarations are the same
VB Code:
'Delegate Declarations
Public Delegate Sub MESSAGE_HANDLER(ByRef pSocket As SocketClient)
Public Delegate Sub CLOSE_HANDLER(ByRef pSocket As SocketClient)
Public Delegate Sub ERROR_HANDLER(ByRef pSocket As SocketClient, ByRef pException As Exception)
Private GetMessageHandler As MESSAGE_HANDLER
Private GetCloseHandler As CLOSE_HANDLER
Private GetErrorHandler As ERROR_HANDLER
This is how its done in C#
Code:
'here is where i run into problems
pClientSocket = AddSocket(
new SocketClient(this,
pSocket,
pSocket.RemoteEndPoint.ToString().Substring(0,15),
GetPort,
GetSizeOfRawBuffer,
GetUserArg,
new SocketClient.MESSAGE_HANDLER(GetMessageHandler),
new SocketClient.CLOSE_HANDLER(GetCloseHandler),
new SocketClient.ERROR_HANDLER(GetErrorHandler)));
I cant figure out how do to this in vb.net
any ideas?
Last edited by <ABX; Mar 11th, 2004 at 09:51 PM.
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 7th, 2004, 04:19 AM
#2
Sleep mode
You want to convert the C# code to VB.NET?
-
Mar 7th, 2004, 04:24 AM
#3
Thread Starter
Frenzied Member
ya, this is the part that i cant figure out be
Code:
new SocketClient.MESSAGE_HANDLER(GetMessageHandler),
new SocketClient.CLOSE_HANDLER(GetCloseHandler),
new SocketClient.ERROR_HANDLER(GetErrorHandler))
the constuctor is declared like this:
Code:
SocketServer pSocketServer,
Socket pClientSocket,
String strIpAddress,
Int16 iPort,
Int32 iSizeOfRawBuffer,
Object pUserArg,
MESSAGE_HANDLER pfnMessageHandler,
CLOSE_HANDLER pfnCloseHandler,
ERROR_HANDLER pfnErrorHandler
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 7th, 2004, 04:31 AM
#4
Sleep mode
C# vs VB.NET
this = me
arrays [] = ()
Can you post the two classes because I can't figure out some part ?
-
Mar 7th, 2004, 04:44 AM
#5
Thread Starter
Frenzied Member
maybe this will help
First Attempt
VB Code:
Dim newSock As New SocketClient(Me, _
pSocket, _
pSocket.RemoteEndPoint.ToString().Substring(0, 15), _
GetPort, _
GetSizeOfRawBuffer, _
GetUserArg, _
[U]New SocketClient.MESSAGE_HANDLER(GetMessageHandler)[/u], _
[U]New SocketClient.CLOSE_HANDLER(GetCloseHandler)[/u], _
[U]New SocketClient.ERROR_HANDLER(GetErrorHandler)[/U])
the error message under all 3 is " 'delegatename' Is a Delegate Type. Delegate Construction Permits only a single AddressOf Operator in the argument list. ect."
My second Attempt At getting it to work
VB Code:
Dim newSock As New SocketClient(Me, _
pSocket, _
pSocket.RemoteEndPoint.ToString().Substring(0, 15), _
GetPort, _
GetSizeOfRawBuffer, _
GetUserArg, _
[U]New SocketClient.MESSAGE_HANDLER(AddressOf GetMessageHandler)[/U], _
[U]New SocketClient.CLOSE_HANDLER(AddressOf GetCloseHandler)[/U], _
[U]New SocketClient.ERROR_HANDLER(AddressOf GetErrorHandler[/U]))
Message:
"'AddressOf' operand must be the name of the method; parthenahs needed"
I cant figure out what it wants me to do...
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 7th, 2004, 10:54 AM
#6
yay gay
Hey, you have the full C# source code? That's from that a site that has it thru some pages isn't it?
If you have the full code in a .cs file or whatever it is could you post it here plzkthx?
\m/  \m/
-
Mar 7th, 2004, 01:47 PM
#7
Thread Starter
Frenzied Member
yeah, if you follow the link in the sample application a newer version is posted here and downloadable: www.continuumtechnologycenter.com
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 7th, 2004, 02:57 PM
#8
yay gay
Thanks, only now i realised that those classes don't use any kind of "events", just delegates. That sucks 
Also it doesnt use propertys or things like that 
edit: I dont f***ing get how anyone is suposed to work with that in a .NET language, I won't use it
Must be some C or ASM coder that programmed that socket class in c# by mistake
Last edited by PT Exorcist; Mar 7th, 2004 at 03:35 PM.
\m/  \m/
-
Mar 7th, 2004, 05:11 PM
#9
Thread Starter
Frenzied Member
VB Code:
'I did the following to fix my problem
Dim pMessage_Handler As SocketClient.MESSAGE_HANDLER
pMessage_Handler.Combine(pMessage_Handler, GetMessageHandler)
Dim pClose_Handler As SocketClient.CLOSE_HANDLER
pClose_Handler.Combine(pClose_Handler, GetCloseHandler)
Dim pError_Handler As SocketClient.ERROR_HANDLER
pError_Handler.Combine(pError_Handler, GetErrorHandler)
Im not sure if this works or not because i cant figure out why i cant get the server class to get the data, prolly because i made a small mistake somewhere.
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 7th, 2004, 05:14 PM
#10
yay gay
Can you even make the socket class connect for an FTP for example and stay connected? I can send/receive the 1st line but after that it will just disconnect..
\m/  \m/
-
Mar 7th, 2004, 07:15 PM
#11
Thread Starter
Frenzied Member
I still cant figure this out???
VB Code:
Public Class Client
Public Delegate Sub MESSAGE_HANDLER(ByRef pSocket As SocketClient)
Public Function DoSomethingWithDelegate(ByRef pfnMessageHandler As MESSAGE_HANDLER)
'Do whatever with delegate
End Function
End Class
VB Code:
Public Class Server
Public Delegate Sub MESSAGE_HANDLER(ByRef pSocket As SocketClient)
Public Function PassDelegate()
'Create Delegate
Dim Test as New AsyncCallback(AddressOf CallbackMethod)
'Now how can i pass Test to DoSomethingWithDelegate ???
End Function
End Class
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 7th, 2004, 07:28 PM
#12
What is it you are trying to do here? I mean how is the code you posted suppose to work? Or what is the C# that is converts from?
-
Mar 7th, 2004, 08:13 PM
#13
Thread Starter
Frenzied Member
Im almost certain that my problem is in this method
C# Version Of Method
Code:
private void AcceptThread()
{
Socket pSocket = null;
SocketClient pClientSocket = null;
try
{
// Create a new TCPListner and start it up
GetTcpListener = new TcpListener(Dns.Resolve(GetIpAddress).AddressList[0],GetPort);
GetTcpListener.Start();
for (;;)
{
try
{
// If a client connects, accept the connection.
pSocket = GetTcpListener.AcceptSocket();
}
catch (System.Net.Sockets.SocketException e)
{
// Did we stop the TCPListener
if (e.ErrorCode != 10004)
{
// Call the error handler
GetErrorHandler(null, e);
GetErrorHandler(null, new Exception("Waiting for new connection 1"));
// Close the socket down if it exists
if (pSocket != null)
if (pSocket.Connected)
pSocket.Close();
}
else
{
GetErrorHandler(null, new Exception("Shutting Down Accept Thread"));
break;
}
}
catch (Exception e)
{
// Call the error handler
GetErrorHandler(null, e);
GetErrorHandler(null, new Exception("Waiting for new connection 2"));
// Close the socket down if it exists
if (pSocket != null)
if (pSocket.Connected)
pSocket.Close();
}
try
{
if (pSocket.Connected)
{
Debug.WriteLine(pSocket.Connected);
// Create a SocketClient object
pClientSocket = AddSocket(new SocketClient(this,
pSocket,
pSocket.RemoteEndPoint.ToString().Substring(0,15),
GetPort,
GetSizeOfRawBuffer,
GetUserArg,
new SocketClient.MESSAGE_HANDLER(GetMessageHandler),
new SocketClient.CLOSE_HANDLER(GetCloseHandler),
new SocketClient.ERROR_HANDLER(GetErrorHandler)));
// Call the Accept Handler
GetAcceptHandler(pClientSocket);
// Wait for a message
pClientSocket.Receive();
}
}
catch (Exception e)
{
// Call the error handler
GetErrorHandler(null, e);
GetErrorHandler(null, new Exception("Waiting for new connection 3"));
}
}
}
catch (Exception e)
{
// Call the error handler
GetErrorHandler(null, e);
GetErrorHandler(null, new Exception("Shutting Down Accept Thread"));
// Close the socket down if it exists
if (pSocket != null)
if (pSocket.Connected)
pSocket.Close();
}
}
VB.Net Ported Version Of Method
VB Code:
Private Sub AcceptThread()
Dim pSocket As Socket = Nothing
Dim pClientSocket As SocketClient = Nothing
Try
'// Create a new TCPListner and start it up
GetTcpListener = New TcpListener(Dns.Resolve(GetIpAddress).AddressList(0), GetPort)
GetTcpListener.Start()
Do ' Replaces for(;;) ....
Try
'// If a client connects, accept the connection.
pSocket = GetTcpListener.AcceptSocket()
Catch e As System.Net.Sockets.SocketException
'// Did we stop the TCPListener
If Not (e.ErrorCode = 10004) Then
'// Call the error handler
GetErrorHandler(Nothing, CType(e, SocketException))
GetErrorHandler(Nothing, New Exception("Waiting for new connection 1"))
'
'// Close the socket down if it exists
If Not (pSocket Is Nothing) And pSocket.Connected Then
pSocket.Close()
End If
Else
GetErrorHandler(Nothing, New Exception("Shutting Down Accept Thread"))
'Exit For
Exit Do
End If
Catch e As Exception
'{
'// Call the error handler
GetErrorHandler(Nothing, CType(e, SocketException))
GetErrorHandler(Nothing, New Exception("Waiting for new connection 2"))
'// Close the socket down if it exists
If Not pSocket Is Nothing Then
If (pSocket.Connected) Then
pSocket.Close()
End If
End If
End Try '
Try
If (pSocket.Connected) Then
'{
Debug.WriteLine(pSocket.Connected)
'TODO: Check Code
'//Create Delegates
pClientSocket = AddSocket(New SocketClient(Me, _
pSocket, _
pSocket.RemoteEndPoint.ToString().Substring(0, 15), _
GetPort, _
GetSizeOfRawBuffer, _
GetUserArg, _
[B]New SocketClient.MESSAGE_HANDLER(GetMessageHandler), _
New SocketClient.CLOSE_HANDLER(GetCloseHandler), _
New SocketClient.ERROR_HANDLER(GetErrorHandler)[/B]))
'// Call the Accept Handler
GetAcceptHandler(pClientSocket)
'// Wait for a message
pClientSocket.Receive()
End If '} // if socket.Connected
'} // try
Catch e As FieldAccessException
'// Call the error handler
'GetErrorHandler(Nothing, e)
GetErrorHandler(Nothing, New Exception("Waiting for new connection 3"))
End Try
Loop 'Next
Catch e As Exception
'// Call the error handler
GetErrorHandler(Nothing, CType(e, SocketException))
GetErrorHandler(Nothing, New Exception("Shutting Down Accept Thread"))
'// Close the socket down if it exists
If Not (pSocket Is Nothing) And pSocket.Connected Then
pSocket.Close()
End If
End Try
End Sub
[Full source Files Attached]
Last edited by <ABX; Mar 7th, 2004 at 09:03 PM.
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 9th, 2004, 03:51 PM
#14
Thread Starter
Frenzied Member
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 9th, 2004, 11:05 PM
#15
Sleep mode
<ABX , do you really have to use this class ? Why don't you try another code as PT Exorcist is complaining too
-
Mar 10th, 2004, 10:50 AM
#16
Thread Starter
Frenzied Member
yeah, maybe i'll start fresh and write my own classes. I just thought it would be interesting to port.
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 10th, 2004, 11:01 AM
#17
Sleep mode
Originally posted by <ABX
yeah, maybe i'll start fresh and write my own classes. I just thought it would be interesting to port.
It's , if the code is correct and working.......
-
Mar 10th, 2004, 03:48 PM
#18
when working with Delegates , you need to create a Sub that matches the Delegate ( to handle it ) , so what you should do is something along these lines ...
VB Code:
#[color=blue]Region[/color][color=gray] " Private Methods "[/color]
[color=green]'/// place these 3 subs just above the " AddSocket " Sub ...[/color]
[color=blue]Private Sub[/color] getMessageHandling([color=blue]ByRef[/color] pSocket [color=blue]As[/color] SocketClient)
[color=green]'/// handle MESSAGE_HANDLER stuff here.[/color]
[color=blue]End Sub[/color]
[color=blue]Private Sub[/color] getCloseHandling([color=blue]ByRef[/color] pSocket [color=blue]As[/color] SocketClient)
[color=green]'/// handles CLOSE_HANDLER[/color]
[color=blue]End Sub[/color]
[color=blue]Private Sub[/color] getErrorHandling([color=blue]ByRef[/color] pSocket [color=blue]As[/color] SocketClient, [color=blue]ByRef[/color] pException [color=blue]As[/color] Exception)
[color=green]'/// handles ERROR_HANDLER[/color]
[color=blue]End Sub[/color]
[color=green]'/// * * * then your problem area * * * ... [/color]
[color=blue]New[/color] SocketClient.MESSAGE_HANDLER([color=blue]AddressOf[/color] getMessageHandling), _
[color=blue]New[/color] SocketClient.CLOSE_HANDLER([color=blue]AddressOf[/color] getCloseHandling), _
[color=blue]New[/color] SocketClient.ERROR_HANDLER([color=blue]AddressOf[/color] getErrorHandling)))
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Mar 11th, 2004, 09:49 PM
#19
Thread Starter
Frenzied Member
I have given up but that wouldnt work anyway
They are defined like this
VB Code:
Public Delegate Sub MESSAGE_HANDLER(ByRef pSocket As SocketClient)
Public Delegate Sub CLOSE_HANDLER(ByRef pSocket As SocketClient)
Public Delegate Sub ERROR_HANDLER(ByRef pSocket As SocketClient, ByRef pException As Exception)
The Problem is in the code snippit AcceptThread above is that the handlers are already set
For Example
GetMessageHandler is a delegate that already "Pointing" to a sub outside my class. This was set in SocketServer's Contructor but I need to pass the "pointer" to the method to the ScoketClient's Constructor
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 11th, 2004, 11:18 PM
#20
PowerPoster
I haven't had the time to read this whole thread, but here is some VB code that I use to interact with those C# classes that they guy demonstrates on his site:
VB Code:
'CLIENT CODE:
'module variable
Private sClient As New SocketSystem.CSocketClient(10240, Nothing, AddressOf MessageHandlerClient, _
AddressOf CloseHandler, AddressOf ErrorHandler)
Public Sub MessageHandlerClient(ByVal pSocket As CSocketClient, ByVal iNumberOfBytes As Int32)
'Code here.
End Sub
Public Sub CloseHandler(ByVal pSocket As CSocketClient)
'Code here
End Sub
Public Sub ErrorHandler(ByVal pSocket As CSocketClient, ByVal ex As Exception)
'code here.
End Sub
'SERVER CODE:
'module variable
Private sServer As New SocketSystem.CSocketServer
'This goes in a start method.
sServer.Start(System.Environment.MachineName, shtPortNumber, intMaxConnections, intRawBufferSize, Nothing, _
AddressOf MessageHandlerServer, AddressOf AcceptHandler, _
AddressOf CloseHandler, AddressOf ErrorHandler)
Public Sub MessageHandlerServer(ByVal pSocket As CSocketClient, ByVal iNumberOfBytes As Int32)
'Code here.
End Sub
Public Sub AcceptHandler(ByVal pSocket As CSocketClient)
'Code here.
End Sub
Public Sub CloseHandler(ByVal pSocket As CSocketClient)
'Code here.
End Sub
Public Sub ErrorHandler(ByVal pSocket As CSocketClient, ByVal ex As Exception)
'Code here.
End Sub
-
Mar 12th, 2004, 02:24 AM
#21
Sleep mode
-
Mar 12th, 2004, 06:37 AM
#22
Lively Member
Not sure if you figured it out yet but according to the way the code is that you showed it does not appear that the delegates are assigned to any procedures and the must be. All a delegate is, is a parameterized variable for storing the address of a procedure that is assigned to it if it has the same parameters.
But then again I could be stupid and did not notice that they are assigned to something lol.
===============
Tek
===============
-
Mar 12th, 2004, 10:37 AM
#23
PowerPoster
The code I posted above.....WORKS.
I use it in a app. Take the time to look at it, and this whole conversation can end.
-
Mar 12th, 2004, 02:04 PM
#24
Thread Starter
Frenzied Member
hellswrath you missunderstood my problem perhaps this will help clear it up.
I have tried to port these two classes SocketClient and SocketServer to vb.net from C# i wanted to keep the structure the same.
In a Method Called AcceptThread In the SocketServer Class It Creates an Instance Of a SocketClient Class To Handle when it Accepts a Conection.
Now My Problem is that When the Class SocketServer Is Contructed the Handlers for the events are Given then
VB Code:
'SocketServer Start Method
Public Sub Start(ByVal strIpAddress As String, _
ByVal iPort As Int16, _
ByVal iSizeOfRawBuffer As Int32, _
ByRef pUserArg As Object, _
ByRef pfnMessageHandler As MESSAGE_HANDLER, _
ByRef pfnAcceptHandler As ACCEPT_HANDLER, _
ByRef pfnCloseHandler As CLOSE_HANDLER, _
ByRef pfnErrorHandler As ERROR_HANDLER)
If (GetAcceptThread Is Nothing) Then
'// Set connection values
GetIpAddress = strIpAddress
GetPort = iPort
'// Init the array of SocketClient references
GetSocketClientList = New ArrayList
'// Save the Handler Functions
GetMessageHandler = pfnMessageHandler
GetAcceptHandler = pfnAcceptHandler
GetCloseHandler = pfnCloseHandler
GetErrorHandler = pfnErrorHandler
'// Save the buffer size and user arguments
GetSizeOfRawBuffer = iSizeOfRawBuffer
GetUserArg = pUserArg
'// Start the listening thread if one is currently not running
'ThreadStart tsThread = new ThreadStart(AcceptThread)
Dim tsThread As ThreadStart = New ThreadStart(AddressOf AcceptThread)
GetAcceptThread = New Thread(tsThread)
GetAcceptThread.Name = "Accept"
GetAcceptThread.Start()
End If
End Sub
VB Code:
'SocketClient Constructor
Public Sub New( _
ByRef pSocketServer As SocketServer, _
ByRef pClientSocket As Socket, _
ByVal strIpAddress As String, _
ByVal iPort As Int16, _
ByVal iSizeOfRawBuffer As Int32, _
ByRef pUserArg As Object, _
ByRef pfnMessageHandler As MESSAGE_HANDLER, _
ByRef pfnCloseHandler As CLOSE_HANDLER, _
ByRef pfnErrorHandler As ERROR_HANDLER)
'// Set reference to SocketServer
GetSocketServer = pSocketServer
'// Init the socket references
GetClientSocket = pClientSocket
'// Set the Ipaddress and Port
GetIPAddress = strIpAddress
GetPort = iPort
'// Set the handler functions
GetMessageHandler = pfnMessageHandler
GetCloseHandler = pfnCloseHandler
GetErrorHandler = pfnErrorHandler
'// Create the raw buffer
GetSizeOfRawBuffer = iSizeOfRawBuffer
ReDim GetRawBuffer(GetSizeOfRawBuffer)
'// Save the user argument
GetUserArg = pUserArg
'// Allocate a String Builder class for Application developer use
GetStringBuffer = New StringBuilder
'// Init the NetworkStream reference
GetNetworkStream = New NetworkStream(GetClientSocket)
'// Set the async socket function handlers
GetCallbackReadFunction = New AsyncCallback(AddressOf ReceiveComplete)
GetCallbackWriteFunction = New AsyncCallback(AddressOf SendComplete)
'// Set Available flags
IsAvailable = True
'// Init the dispose flag
IsDisposed = False
'// Set these socket options
GetClientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.ReceiveBuffer, 1048576)
GetClientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.SendBuffer, 1048576)
GetClientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.KeepAlive, 1)
GetClientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.DontLinger, 1)
GetClientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Tcp, System.Net.Sockets.SocketOptionName.NoDelay, 1)
End Sub
<ABX goto : The Code Project
To look for....?
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 12th, 2004, 03:36 PM
#25
Sleep mode
to look for best tested classes for server/client sockets . It's here anyways if you would like : http://www.codeproject.com/info/sear...=3%2F12%2F2004
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|