Seeking info on how to use the VB6 Winsock, flow of events, etc - windows

I'm using the MS Winsock control in VB6 and I want to understand things like
"when does the Server Close the
connection (triggering the
Winsock_Close() event), and a
related question:
How do you know
when all the data from a a Post has
been returned?
More info:
I should have mentioned: I've already read the MSDN description, etc., but it doesn't actually explain what's happening. E.g., it explains the the Close() event fires when the Server ends the connection but doesn't explain what would cause the connection to end and whether a broken connection would trigger a Close event, etc.
And none of the MSDN descriptions explain know when all the data has arrived. (I suspect it's the Close even firing).

You might want to try out the following walkthrough
tcp.oflameron.com/
You can find the complete code here
If you have any Qs in particular, plz ask here...
GoodLUCK!!
- CVS

Using the Winsock Control at http://msdn.microsoft.com/en-us/library/aa733709(VS.60).aspx
MSDN Search of "Winsock control" at http://social.msdn.microsoft.com/Search/en-US?query=Winsock+control&ac=8
Documentation Lacks
The documentation will not provide the information you are asking for. This is an ActiveX control that allows you to connect computers through TCP/IP protocol stacks.
The information you want applies to how these computer "talk" (the protocol). That totally depends on the server application and client application that are communicating. For instance, if I am connecting to the FTP Service of another computer, the server will not close the connection until I send the appropriate command or until the server detects an idle connection. On the other hand, some services will close the connection on any invalid command, especially SMTP Servers will tighten security.
You need to check out the documentation of the service you are connecting with. The documentation will tell you how to send commands, command format, response codes, how commands are acknowledge, and so on.
SAMPLE: VBFTP.EXE: Implementing FTP Using WinInet API from VB at http://support.microsoft.com/kb/175179

Related

RPC authenthification explained with windows api

I would like to make a IPC between two processes using Windows RPC. Please explain me like I am five how my application should achieve good security. I want to use ncalrpc protocol (processes on the same computer). More exactly:
How my client application knows that the server is trusty?
How my server know if the callee is the trusted one?
What options do I have? I didn't get RpcBindingSetAuthInfo function.
Thanks
For a local connection having the client authenticate the server is fairly hard (for example confirming that some other service did not start in place of the desired program) but having the server identify the client is not, call RpcBindingInqAuthClient and use the username to determine what action to take, or just use RpcImpersonateClient if you can rely on existing secured objects. Most of the RPC security apparatus is for remote connections rather than ncalrpc.

Anybody implemented IceLink in Xamarin?

I am going to develop an application which includes Audio/Video/Text chat.
I read IceLink documentation and demo. From that what I understood is we need to do signalling using WebSync to connect two peers.
But I couldn’t understand how to do it.
My questions are (suppose A wants to call B):
1. How A knows the address of B (whatever it may be like, ID or anything)
2. How B comes to know that A is calling him/her
We once build an App with P2P Connection via IceLink.
But we didn´t use the WebSync Component.
To establish a RTC Connection you need a non-P2P communcation to do the Handshake first.
With this Handshake all neccessary information is transmitted, and icelink can try to reach the other peer.
We used Microsoft SignalR for that since it is a serverside-javascript which can push messages to connected clients.
1.this is part of the handshake
2.Signaling via SignalR (e.g.)
I followed their example and achieved the same thing as you are intending to.
You need to handle call making on the server-side and somehow communicate the session id to another user . as simple as that.

IOCP, AcceptEx, overlapped and WSAEINVAL

I have a server that uses IOCPs, sockets and overlapped. Initially everything is just wonderful. The listening socket hands off to a newly created socket using AcceptEx on an IOCP. I can handle thousands of connections just fine.
When the server process falls behind in processing, it will close and disconnect the listening port. When it catches back up, it will reestablish the listening port with a new IOCP.
The issue I have run into is that on after reestablishing the listening port, and a new connection arrives, I attempt to accept using the exact same code path as above. The AcceptEx fails with WSAEINVAL.
I know I have left out some details (and the devil is always in the details, no?) -- but would appreciate assistance on where I should be looking.
If a curious soul would like more information, I'd be happy to supply.
It's hard to guess at what your problem might be given you don't show any source code, but...
There's no need to close the listening socket, simply stop posting new AcceptEx() calls and the server will not be able to accept any new connections.
if you really want to close the listening socket as well then do not close the IOCP and make sure you use the same IOCP when you recreate the listening socket.
I will answer my own question, because I have figured out what the underlying issue was. One thing that was critical to the issue, but was not stated in the problem statement was that the server had sub-processes.
It turns out that while the default behavior in windows is to not have handles inherited by sub-processes, the behavior of winsock is the opposite: handles are inherited by sub-processes unless explicitly set to no-inherit on creation.
Creating sockets with non-inheritable handles solves this problem. I hope that this helps someone out there that runs into this issue.

Is there a good guide to interpreting the Firebug net panel?

I’m using the Net panel in Firebug to evaluate the performance of web pages I’m writing.
Specifically, I’m wondering what the precise meaning is of the stages for each resource that’s downloaded (i.e. DNS lookup, Connecting, Blocking, Sending, Waiting, receiving).
But more generally, is there a Firebug guide where I can look this stuff up?
The various stages correspond to the various states of the connection being made for the resource. I don't know of any documents on them and a quick look around the Firebug network page doesn't show any explanations. There is some documentation in the resources area (wiki) of the Firebug site, though it looks like its subtly different than what is actually presented in the interface. They seem reasonably obvious to me, but I suppose I could be wrong, too.
DNS lookup - the name of the remote server is being resolved to an IP address
Connecting - a TCP/IP connection is being opened to the remote server
Blocking - the client is waiting for another request to complete (or a thread to become available) before sending the request
Sending - the client is sending data to the remote server
Waiting - the client is waiting on a response from the remote server
Receiving - the client is reading data from the remote server
You can read up on HTTP headers.
And for the whole firebug net panel you can read this.
Although it doesn’t include an answer to this question, Amy Hoy and Thomas Fuchs’s PDF ebook JavaScript Performance Rocks! has a lot of good information about measuring web page performance using Firebug

Windows sockets

Does windows closes idle sockets? I mean if I'm a client connecting to a service on Windows server, is it possible that Windows server closes the connection after certain idle-time?
If yes, how to change this behaviour, or at least change the idle-time value?
Thanks in advance.
The behavior depends on the SO_KEEPALIVE socket option. Here's the MSDN page about it. After some further digging you can adjust the KEEPALIVE semantics with a WSAIoctl and the SIO_KEEPALIVE_VALS Control Code.
I find, that if you control both ends, it is usually better to implement keepalive messages as part of the protocol used to communicate between the client and server instead of relying on SO_KEEPALIVE.
I would imagine that depends on the protocol, implementation and perhaps server config.
PuTTY has an option to prevent timing out of SSH sessions by periodically sending null packets to the server - I suspect this is a simply packet with no actual payload. Perhaps you could implement something like this?
On MSDN you will find that the defaul keep-alive timeout is set to 2 hours. You are maybe able to manipulate this by using setsockopt/SO_SNDTIMEO/getsockopt

Resources