General Last Updated: 01/27/2007 |
Frequently Asked Questions for General:
- Accept live telnet connection
- AOwner argument, what is it
- Application.ProcessMessages
- Bandwidth control
- Bandwidth throttling
- BCB 6 install
- Blocking or no blocking, what's the difference
- BPL file missing at exe time error
- Cannot convert protocol error
- Cannot convert protocol
- Change the limit of sockets in Win9x
- Client and server on same pc
- Compatibility with Delphi and BCB versions
- Component not ready
- Connecting from LAN to same LAN via WAN side of router
- CPU usage 100 percent
- Debug a service application
- Delphi 2005 personal
- Detect all IP addresses on a network
- DnsLookup versus TDnsQuery component
- Firewalls and Socks
- Free Pascal
- How can the client side detect when the connection is broken?
- How can I get extended information about my net-configuration such as adapters, subnet-mask, gateways etc.?
- Installing on BCB
- IP's and subnet
- Message list archive
- Kylix and ICS
- Limits of windows
- Local and remote port
- Mac address of a NIC
- Max size of message queue
- Message pump in service application
- Message pump, what is that
- No route to host
- Port names are not working
- Remote printing
- ResolveIP, what does it return
- Security
- Server does not accept all simultaneous connections
- Server on win9x refuse to have lots of serialized connections
- Size of a console program
- Sniffer tcp/ip
- SSL Socket support
- Stress tool and firewalls
- Timeout time of TIME_WAIT
- Upper limit of sockets
- Using a lot of sockets
- Wake up a computer
- Winsock error 10038
- Winsock error 10035
Accept live telnet connection
Francois PIETTE francois.piette@overbyte.be 01/04/2003 |
Can someone tell me if it's even possible to start an app that uses TnCnx and have it use a telnet connection that has already been established?
You can use TnCnx1.Socket.Dup(TheWinSocketHandleFromOtherApp); |
AOwner argument, what is it
Steve Williams stevewilliams@kromestudios.com 06/03/2001 |
Before whacking any old value into the constructor, it is important to understand what the parameter means and the effects of different values.
The AOwner parameter for a constructor of a class derived from TComponent tells the object being created that it is owned by another object. When the owning object is destroyed, all owned objects are destroyed along with it. This is not the only side-effect though. When an object is given an owner, all objects already owned by that owner object are notified that this new object is being created via the Notification() method. And all objects owned by those objects are notified, and so on down the chain of ownership. In a large project, this can result in hundreds or perhaps thousands of redundant function calls for each object created with an owner. The same thing happens when an owned object is destroyed. Each object at the same level in the ownership tree and below are notified that the object is being destroyed, once again resulting in potentially thousands of redundant function calls. The automatic destruction of owned objects can also cause problems when the object is destroyed but your application still tries to use the object. It is at that point that you can say hello to an access violation. You can also specify NULL as an owner. This means that the object has no owner and that you are ultimately responsible for life and death of the object. This is my preferred way to create objects derived from TComponentas it is the most efficient (no redundant calls to thousands of Notification methods) and you have total control over the life of the object. |
Application.ProcessMessages
Wilfried Mestdagh wilfried@mestdagh.biz 05/08/2003 |
Application.ProcessMessages is something people like to call often, but what is it, what are the benefits and what are the disadvantages
What is it? It calls the message pump, which handles incoming Windows messages until there is no more messages in the message queue. Normally it is bad practice to call it directly, unless you are sure you know what you are doing, since Delphi already calls the message pump already while your application is idle. What are the benefits of calling it? To be honest... None. If your application is written right, you will never ever have to call it directly. If you really need to call it, you might want to re-evaluate the design of your application. But why do people like to call Application.ProcessMessage, if it is so bad? Well, if your application does not respond when you want it, it is very easy to just call it. It is generally wrong because Delphi does all that for you. People often call it to update the display of some control component, i.e. a Label. But in such cases you are better off calling the Update method of the control itself, which will send (not Post) a message to the window of the control itself and cause the control to be updated immediately. Almost all control components have an update method, i.e. Label.Update. Also, many people believe they have to pause their application using wait loops while some event happens because they don't understand Windows programming. Then they feel it necessary to insert a call to the message pump in the wait loop or their application will freeze while waiting. This is generally unnecessary and wastes lots of CPU time. In these cases it is best to re-evaluate the design of the application and rewrite it if necessary to take advantage of the event-driven nature of Windows programming. What are the disvantages? A lot! For example if you call Application.ProcessMessages from within an event of a component, and if that component generates its events from within the message pump, then you are in deep trouble. In fact, you are calling yourself at that moment. I have made a simple example of what can happen with a simple timer. You can download it at: http://www.mestdagh.biz/ics/demos/ReEnterTest.zip As an example, suppose you call the message pump in the OnReceive event of an ICS component. From there you call a Receive method to receive the data. But your code is badly written and slow, so you decide to call Application.ProcessMessages, and if at that time already new data is received by WinSock, your OnReceive handler will be called again before it ends. When the second instance of your OnReceive finishes, the next line of the first instance will continue. You can then imagine what can happen... Corrupted, lost or duplicated data; infinite loop and all sorts of Bad Things. This is not a component issue, it is the way Windows was design. Before you call the message pump you must learn how the Windows messaging system works, and how messages are transformed to events. Note that a modal form is calling the message pump also (because it is idle and just waiting for messages, eg a mouse click), meaning that if you display for example a dialog box, then you are indirect calling the message pump, doing the same thing. |
Bandwidth control
Wilfried Mestdagh wilfried@mestdagh.biz 22/08/2005 |
Designed for FTP client, but useable general in a thread:
http://www.smatters.com/ics
.
ThrottledWSocket and ThrottledFTPSrv: http://www.xantorrent.pwp.blueyonder.co.uk/ics/ThrottledWSocket.zip . |
Bandwidth throttling
Francois PIETTE francois.piette@overbyte.be 01/04/2003 |
I want the user to be able to limit transfers with the multiples of 1KB
Bandwidth is not expressed in KB (KiloByte) but in KB/S (Kilo Byte per second, note the uppercase 'B') or more often Kb/s or Kbps (Kilo bit per second, note the lower case 'b'). from replying to its clients with steps less than 4 kb when the On....datasent is fired every 4KB? Bandwidth has to be considered as a mean value for a given time period such as 10 seconds. If you reduce too much the time period, your bandwidth will have only one value, called an 'instantaneous' value which is the line speed. You should also remind you that your data is encapsulated in packets with various headers. You must try to send the largest packet size you physical medium support to minimize the header overhead. |
BCB 6 install
Francois PIETTE francois.piette@overbyte.be 14/05/2003 |
> When I open and click on install appears the follow error message:
|
Blocking or no blocking, what's the difference
Davie Davie@smatters.com 21/12/2002 |
I would like to know the main difference between ICS and Indy. I know the difference is blocking and non-blocking but: What does it means? Which one is better? Which is more reliable?
I will give simple answer, I hope I don't flare up tons of replies, this is just meant to be an encapsulation. Everybody has their own strong preference for particular reasons. Blocking vs NON-Blocking: NON-Blocking: Think of windows programming. It's event driven. Your program doesn't hog the system or waste system time if no buttons are being clicked on your program. But as soon as a button is clicked then a message is sent to your app and then your app does what it needs to do and then your app goes into hibernation again. Pretty efficient and this is what's called "EVENT-DRIVEN". This event-driven way is also called NON-BLocking, and the non-block way is also thought of as ASYNC way of doing things. NON-Blocking is because if you had these lines: Connect GetFile CloseConnection The "Connect" function returns PRONTO without even making sure it was completed successfully. So, then the next statement "GetFile" would fail because it's trying to get a file when it may not even be connected to the server yet :) And then the CloseConnection happens and it probably fails as well :) Event-driven instead: So, you need to design your program like windows program. You have the main app call a function and from then on you rely on events. Just like ButtonClick and TComboChange and other events in Delphi, these ICS components have events that allow you to control the logical flow of stuff. So you may just have one line: Connect And that's it. Then in the connect's FinishEvent, you would then put one line of code that says "GetFile" and that's it, one line. Then in the getFile's FinishEvent you stick one line that says "CloseCOnnection" and that's it. Now I'm talking in fake code here, but you get the idea. So, since you call one line of code for each event, hasically your program goes back to sleep until the FinishEvent is triggered. It's a little more complex but pretty much the case. Blocking: Think of writing a program in DOS, your program is actually running the entire time, constantly doing calculations or looooooooping waiting for the user input etc... That's a top-down type of programming instead of event-driven. This is also known as SYNC way of doing sockets and IP communications. It's called blocking because if you called these functions: Connect GetFile CloseConnection Then the functions do NOT return until they are completed, so the connect may take 8 seconds before the next line executes. And the getfile may take 5 minutes before it returns and then the closeconnection may only take 1 second. ASYNC vs SYNC Now that you have seen the logical difference between topdown/blocking/sync methods and then eventdriven/non-blocking/async methods, I will give my own 2 cents worth on which is better. And again, please don't flare, Just trying to lay down the facts. ASYNC PROs Typically less system cpu usage. Not by a great deal, but still a few percentage points. Event Driven - so if you are used to that, then you will feel at home. You can perform MULTIPLE component tasks at the same time. SYNC PROs Not quite as efficient as ASYNC, BUT IF YOU USE WAITFORMULTIPLEOBJECTS instead of the sleep(0), then it will be every bit as efficient as the ASYNC. Top down - so if you are used to that, then you will feel at home. Better portability. You can design a function who's sole purpose in life is to perform a certain thing. Then if you change from ICS to INDY or WinShoes or NMFT then all you do is replace that one function and everywhere in your app that you refer to that function stays the same. No massive logic changes. PERSONAL OPINION: I will start by saying that there are as many opinions on these issues as there are people using it :) Ok, I like ASYNC if you want your logic code to be placed into the events that are triggered by the method's component. I like SYNC if you want your logic all in one spot. I like SYNC if you have multithreaded stuff and use the WaitForMultipleObjects to make it super efficient. I like SYNC if you plan to port code a lot. In actuality I use a mixture of ASYNC and SYNC in my apps depending on my needs. I like ASYNC if I want to do multiple component tasks at a time, for example: let's say I wanted to upload 5 files at once, I COULD create 5 tfptclient objects and then start them all going at the same time and using the events in each component to do the work. So, instead of uploading one file and then wait and then upload another and then wait etc.... I can upload all 5 at the same time. This may or may not be faster than doing them separately, but the possibility for faster is surely there. Also, I could upload to 5 different servers at the same time and in that case most likely it'll be done faster with ASYNC, especially if one of the servers is a slow one. SPECIAL NOTES: Please beware that if you click on buttons while an operation is not completed, it may cause your buttonclick event logic to fail if the button click logic starts another component command. Please beware that if you use SYNC methods that if you try to CLOSE the form, that it will not close the form until the function is completed, so you may have to wait a bit, where-as the ASYNC, you can accomplish the close faster. Even though CPU monitors will report 100% utilization for SYNC operations, it's not true. If you run other apps, they will not appear to be slowed down. The SYNC methods are not cpu hogs, they don't demand extra cpu time, they just take whatever cpu time is available and uses it (basically). There's really just a few % points that are inefficiently used by SYNC and as CPUs get faster, the % points grabbed get smaller. AND you can get around that by using the WaitForMultipleObjects instead of the Sleep(0) in the waituntilready. Then it goes into hibernation just like the ASYNC methods do. CONCLUSION: They both have a purpose in life and it's up to you to decide to use them or not. |
BPL file missing at exe time error
Carl Schulz kantorenhuis@hotmail.com 7/2/2005 |
Beginners problem: Why does my exe not run on other computers ? I get a .BPL file missing error.
After following install instructions under Delphi 7 I ended up with examples running fine on the development pc but not on other systems. Viewing the Information option on the Run menu (just after a Compile of my test project) I noticed a dependency with the following runtime libraries ... rtl70.bpl, vcl70.bpl and IcsDel70.bpl. IcsDel70.bpl can be found under C:\Program Files\Borland\Delphi7\Projects\Bpl. I also noticed my exe was real small. Selecting Component / Install Packages / Add and browsing to IcsDel70.bpl then adding it. Recompile Solved the problem. Exe's are much bigger now ;-( |
Cannot convert protocol error
Francois Piette francois.piette@overbyte.be 10/12/2004 |
When I try to connect with ftp server, the library produces the error "500 ESocketException: connect: WSocketResolveProto: Cannot convert protocol 'tcp', Error #11004". Why it is produced and how I can solve it
This is usually caused by a virus which destroy or move the "protocol" file used by Windows to resolve protocol names (such as "tcp") to protocol number. To get rid of that, you must: 1) Update your anti-virus 2) Scan your computer and remove the virus if it is still there 3) Remove TCP/IP protocol stack 4) Install TCP/IP back Note that the current ICS-BETA now use hardcoded protocol numbers for udp and tcp because the virus you had become more and more common. So ICS programs are no more affected by this virus. |
Cannot convert protocol
Francois PIETTE francois.piette@overbyte.be 14/01/2006 |
But when I compile the HTTPGet demo I get the following error: project httpget.exe raised exception class esocketexception with
message "wsocketresolveproto:cannot convert protocol 'tcp', Error #11004' What am I missing that would be causing this? You have been infected by a virus which mess your TCP/IP settings and give this error message. The virus either destroy or move the file "protocol" (a text file without extension) which is used to convert protocol names to protocol numbers. Some other virus change the registry keys which tells winsock where the file is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath. Normal (on a NT/2K/XP system) data type is REG_EXPAND_SZ and value is value %SystemRoot%\System32\drivers\etc). |
Change the limit of sockets in Win9x
Ing. Pedro E. Colla colla@pec.pccp.com.ar 28/04/2001 |
The default number for Win9x is about 100.
You could see how many sockets do you have counting the returning lines of netstat -a (if you have a wc clon it would be "netstat -a | wc --lines"). You could increase that number manipulating the Registry HKEY_LOCAL_MACHINE System CurrentControlSet Services VxD MSTCP MaxConnections "256" "" If the entry doesn't exists create it. |
Client and server on same pc
Duilio Foschi dedalus@yifan.net 22/09/2001 |
> Can I establish a socket connection with 2 EXEs both running on same pc
Yes, use Addr '127.0.0.1' or 'localhost' and a high number port, e.g. > 1024 (lower ones could be in use). To see the ports that are in use run Netstat -a from the command line. |
Compatibility with Delphi and BCB versions
Will Godfrey will@omicron-technologies.co.uk 22/12/2002 |
After much web searching it looks like it's just "bad form" to need the DesignInterface to exist on the end users machine. It's not re-distributable under Borland T+C. Ok I'm using ICS on BCB 5 Standard and this is what I did to get it working. Downloaded the ICS ZIP Copied the VC32 folder into a sub folder under my C Builder LIB folder just incase any path searching was needed. Load and tried to compile (as per readme instructions) and got 'dsngintf.dcu' missing I went to Project->Edit Option Source and adjusted the line <PFLAGS> to read <PFLAGS value="-$YD -$W -$O- -v -M -JPHNE -LUvcl50"/> Then did a File->Save Recompiled and this time got an error about 'vcldbx50.lib' So back I went into 'Edit Option Source' and removed all instances of this file (under LIBRARIES and SPARELIBS). Recompiled and got an error about 'vclbde50.lib' So back I went into 'Edit Option Source' and removed all instances of this file (under LIBRARIES and SPARELIBS). Compiled fine on this attempt, so I installed the package (which installed fine on the tool bar) and now I've spent all day getting to grips with TWSocket and UDP broadcasts! Not come across a problem yet but then again I've not tried all the components ICS installs. |
Component not ready
Francois PIETTE francois.piette@overbyte.be 04/06/2001 |
> I get an error 'POP3 component not ready'. What is wrong? ICS components are non-blocking. Each method is just a request to do something. Control returns back long before the task is done. You get an event when the task is finished so that you can do whatever is needed at that time, including requesting the next operation. Some components have xxxSync methods to be blocking. You should not use them because it gives not optimal performances. |
Connecting from LAN to same LAN via WAN side of router
Ian Baker ibaker@ntlworld.com 20/04/2003 |
On every router that I've come across, be it hardware or software (e.g Linux), you are unable to connect from LAN to LAN via the WAN address.
In my own case (a Netgear RT-314), trying to connect to my web server gets you the built-in configuration web server, as the router knows that you are a local LAN address and therefore assumes that you want to talk to the router, rather than something on the LAN. |
CPU usage 100 percent
From the archieve 04/06/2001 |
Don't be fouled by that Task Manager. Your app use 100% CPU because no other apps requires CPU time-slice. Like you noticed, you can start other progs and use them without problems.
If I remember right, there's a thigt loop somewhere which use Sleep(0) to let windows give CPU to other apps that need it. But if no other apps are running, that loop uses 100% CPU. ---------------------------------------- Nope, not a bug, in fact, sleep(1) will MAKE your app suck more CPU time away than Sleep(0). It's just that the CPU monitoring system doesn't do a real good job at showing the percentages. See the sleep(0) makes it non-hogging, that means if no other apps are running, your app will get 100%, then if you run 5 apps, your app will take NO MORE than 20% if running in background. ---------------------------------------- HIGH CPU USAGE: If you have just one thing running and it's YOUR program, then if you are SYNC then it will show HIGH CPU usage which is in fact correct, BUT it's NOT a problem because it's NOT A HOGGING function. That means as you run other apps, YOUR CPU usage will drop according to how much CPU usage the other apps need. The only problem arises when you have multiple threads running and not much else, what will end up happening is that you have your WaitUntilReady loop constantly switching to the next thread with the Sleep(0) statement and then you end up with a trashing war for switching tasks :) So, if you were interested in transferring data at TOP MOST speed with MULTIPLE threads (more than about 6) then you should redo the waituntilready function and change the Sleep(0) with something like WaitMessage; Then it actually HALTS the process until another message is placed into the threads queue and is much more efficient and thus makes it AS EFFICIENT as the ASYNC. |
Debug a service application
Wilfried Mestdagh wilfried_sonal@compuserve.com 06/03/2001 |
Write your whole application in a separate object. Then you can create the object in a 'normal' application to debug. When it's all working fine you create the same object in a service app.
|
Delphi 2005 personal
Ken Jobling vk3kjc@netspace.net.au 14/05/2005 |
I have a problem installing ICS (latest download) onto Delphi 2005 Personal.
I get error message: "[Fatal Error] IcsDel90.dpk(47): E2202 Required package 'xmlrtl' not found" at: "requires designide, xmlrtl, etc" A quick search of the Internet then found a solution - a fake xmlrtl.dcp file which provides the required units but without the implementation section. You van find it here: http://andy.jgknet.de/oss/kylix/wiki/index.php/Delphi_2005_Personal_Edition_xmlrtl.dcp_fake http://www.delphipraxis.net/post364548.html "http://www.pri-dev.net/tutorial2,de.html |
Detect all IP addresses on a network
Steve Williams stevewilliams@kromestudios.com 22/09/2001 |
> How to detect all IP addresses on a
> peer-to-peer network (as windows 98) > > How to find then ip addresses of > gateway configuration (like on winipcfg) You use SNMP (Simple Network Management Protocol) to get that sort of info. This is available via snmpapi.dll I believe. I think this is how WinIpCfg and the command line ipconfig utility does it. To detect all the addresses, you need to get the subnet mask and combine it with the machine's IP address to get the range of valid addresses. Then you need to ping each address in that range to see which addresses are currently in use. If your machine's IP is 192.168.0.36 and your subnet mask is 255.255.255.0, then the range of valid addresses is 192.168.0.0 to 192.168.0.255. The first and last (0 and 255) are usually reserved, so you need to check the 1 to 254 range. Ping each one and if you get a response, then a machine is listening on that IP. |
DnsLookup versus TDnsQuery component
Francois PIETTE francois.piette@overbyte.be 21/04/2003 |
TWSocket.DnsLookup is using winsock function which in turn first check the local hosttable, then DNS or WINS. So your program can be fooled by manually editing the hosttable.
TDnsQuery will interrogate the DNS server of your choice. |
Firewalls and Socks
Rich rinskip@home.com 07/06/2001 |
Firewall Proxy :
FTP These firewalls redirect the FTP traffic as a relay. You don't connect to the host you are after but instead to the firewall, once connected the firewall expects a host name to connect to and it will then connect, others will use the username you specify to get the host name, in that case you would give your user name as 'user@ftp.foo.bar'. If all goes well the firewall becomes a transparent layer to the client and server simply relaying commands. Telnet Most of these behave the same. You telnet to the firewall itself and then enter a host name, rather like the FTP method above. Once connected the firewall acts as a transparent layer between yourself and the host. Other Rules govern what you cannot and can do, for an application you may need to change these rules to make an application work. Rules generally allow access to a port in inbound, outbound, redirect and block modes. The first three modes explain themselves. Redirect redirects all connections to a specific IP, say you wanted to direct all inbound traffic on port 80 to a webserver you could use this to prevent people behind the firewall setting up personal web servers. Most goos firewalls use the more flexible approach below called Socks. Socks : Socks is a method of authenticating a user in order to allow a port or set of ports to be used for a connection. With socks you need to use another connection (normally 1080) to authenticate yourself before you make any attempt to connect. Once you are authenticated the server allows connections to and from your address, rules may still govern these connections though, a good example of this is the failure of FTP servers and clients not working over such a firewall, the firewall's rules my block the creation of data connections. Many firewalls use a combination of rules and authentication to determine what you can do. For example, users Phill and Dave are in an office behind a firewall. Phil is a programmer, dave an office junior. Phil often writes applications and uses some exotic programs and maybe uses IRC to get help, dave can happily use IRC and send/get files but Dave cannot. The firewall has been set to reflect the expected ports a user will need and thgus, although authenticated Dave cant use IRC correctly though Phil can. When writing software to work behind a firewall you need to take issues such as this into account. Proprietary Access Methods: There are a few other packages that work differently or to a different standard. Sometimes these changes are enough to break software, other times software specifically for that firewall will be needed, Older versions of MS Proxy Server are a good example of a slightly, but annoyingly broken Socks firewall. Security : A firewall is in place for security reasons, in opening a connection, especially to listen for data, you are running the risk of compromising the firewall, where possible originate connections from a firewall as opposed to listening. Try to make sure that any traffic coming onto the network behind the firewall is controlled such that your application on your machine is the only application exposed to the outside world. Its always a good idea to speak to your sysadmin/customers/target users/boss before doing anything with a firewall to make sure what you want to do can be done and that local policy lets changes to be made. Finally subverting a firewall is stupid. The firewall is there to protect everything behind it and in some cases to enable several systems to share one connection. By breaking the firewall you put all behind it at risk, remember that the majority of Windows systems never have security patches applied. Applying this in ICS : Twsocket supports the use of socks servers via the following properties, methods and events Properties : SocksAuthentication : Choice of SocksNoAuthentication or SocksAuthenticateUserCode SocksLevel : Socks Level, normally 5. Most systems are 4 or 5 SocksPassword : The authentication password SocksPort : The Socks Port of the firewall, normaly 1080 SocksServer : The Firewall/Socks server host SocksUserCode : The Socks Username Events : OnSocksAuthState : Returns the state of the socks connection OnSocksConnected : Returns a sucessful socks connection OnSocksError : Returns a sock error These properties and events are available on all TWsocket derived components |
Free Pascal
Marco van de Voort marcov@stack.nl 27/08/2004 |
Since there seem to be quite some confusion about the extend of fixes FPC needs, I made a ICS/FPC status page, that explains the needed changes, reasons and versions:
http://www.stack.nl/~marcov/ics.html Since the fpc port is only available on CVS, I quickly zipped it, and put it at http://www.stack.nl/~marcov/icsfpc.zip |
How can the client side detect when the connection is broken?
Francois PIETTE francois.piette@overbyte.be 24/12/2001 |
TWSocket already use SO_KEEPALIVEoption to ask winsock to tell when connection is broken. But default timeout are very large (several minutes) and sometimes the option doesn't work at all. If you can, implement it at the application level, sending a kind of NOOP or PING command once a while. |
How can I get extended information about my net-configuration such as adapters, subnet-mask, gateways etc.?
Fredrik Larsson fredrik.larsson@larsson.tc 05/04/2002 |
For Delphi users (not Kylix!) you can use the Internet Protocol Helper API that Microsoft has released. There are two known header conversions that are made. One that is available on ICS User Made pages by Dirk Claessens and Angus Robertson
http://overbyte.alexid.fr/cgi-bin/redirect.cgi?url=http://overbyte.alexid.fr /arch/iphelp.zip
. A second one is made the Delphi Jedi effort and is available through
http://www.delphi-jedi.org/ and ftp://delphi-jedi.org/api/IPHlpAPI.zip
.
If you want further information you can go to Microsoft and check out http://msdn.microsoft.com/library/en-us/tcpip/iphpport_7vz9.asp . If it doesn't work be sure to search for IP Helper API and you will find it. |
Installing on BCB
Albert Fowler webmaster@codegeneration.com 21/07/2001 |
Unzip the files into a directory of your choosing. (Retain Directories)
We will call this directory "ExtractFolder" In BCB Do a Close All if you have any projects or packages open. The do File|Open browse to ExtractFolder\DELPHI\VC32 open the appropriate ICSBCBnn.bpk file. You will see the Package dialog. Click the Compile button. This will compile the package and create the neccessary files for you. If no errors, click Install! ***Here is where most have problems*** If you get an error or error messages saying can not open file blah blah blah: 1) Write these file names down. 2) Do a save all. 3) Do a close all 4) in Notepad, or any other text editor open the bpk file. 5) Scroll down to the LIBRARIES and SPARELIBS section. (This will be like an ini file in pre BCB5 versions and an xml file in BCB5) 6) Remove the filenames that you wrote down. You do not have these files or BCB doesn't know where they are! (Chances are you do not need them for ICS anyway.) 7) After you have removed the references to the files in BOTH sections, save. Back in BCB, File|Open browse to ExtractFolder\DELPHI\VC32 open the appropriate ICSBCBnn.bpk file. You will see the Package dialog. Click the Compile button. If all is well you will have a successful compile. If so, Click Install. Happy-Happy-Joy-Joy. Now you can figure out how to use these wonderfully powerful components! |
IP's and subnet
Wilfried Mestdagh (Revized by Steve Williams) 13/04/2001 |
> What is an IP address?
An IP address is just a 32 bit number represented as a dotted decimal number where the each number represents one byte of the address. For example, take the dotted decimal IP address 10.5.2.1. In hexadecimal this address would be 0A050201 and in base 10 (our everyday numbering system) it is 168100353. You can see that the dotted decimal form of the address is a lot easier to read than both the hexadecimal and the base 10 forms. > What is a subnet mask? A subnet mask allows a machine to determine if a given IP address is on a local network or if it has to be accessed through a gateway to an external network. The subnet mask is used with the IP address to calculate the network address (see next question). According to the specification, a mask should have all '1' bits to the left with the remaining bits to the right set to '0'. Other combinations will also work but are not recommended. A mask can be represented in the same way as an IP address or as a '/' with a number. If a slash is used the following number represents the amount of '1' bits in the mask, eg. 255.255.255.0 is the same as /24. > What is a network address? A network address (let's say the address of the network itself) is the IP address AND the subnet mask. Let me represent this in binary form to explain better. Imagine an IP address of a given machine is 10.0.0.10/24. In binary form this is represented as: IP: 0000 1010 0000 0000 0000 0000 0000 1010 Mask: 1111 1111 1111 1111 1111 1111 0000 0000 Network: 0000 1010 0000 0000 0000 0000 0000 0000 As you can see, by ANDing the IP address with the subnet mask, we get the network address of 10.0.0.0/24. > Are there forbidden IPs? Yes there are. As you can see in previous question it should be already clear that in the case of a network of 10.0.0.0/24 the address 10.0.0.0 is forbidden. This is because it is the network itself. The other forbidden one is the broadcast address. That is the highest possible address in a network. In the above example the broadcast address would be 10.0.0.255. > What is class A, B or C network? There are 3 types of private network and the choice is depending on how large your lan will be. The different classes are recognized by interfaces and routers by high order bits of the address. Class A..C is for large, medium and small networks, D for multicast and E for experimental networks. 0 Class A 10 Class B 110 Class C 1110 Class D 1111 Class E > What is private or public network? A private network is a network that is not routed on public networks such as the internet. In each class there is a reserved range of IP addresses that you can use: Class A: 10.0.0.0 / 8 Class B: 172.16.0.0 / 12 Class C: 192.168.0.0 / 16 This means that the highest possible IP's for these networks are: Class A: 10.255.255.255 Class B: 172.31.255.255 Class C: 192.168.255.255 These addresses will not be routed onto public networks. > What is localhost or the loopback address? 127.0.0.1 is the loopback address on a machine. It means a packet for that address is looped back to the same machine. It does not even come on the network. This is also one of the reserved IP addresses. |
Message list archive
Larry Jackson LarryJackson@iName.com 04/06/2001 |
> Is there a message list archive
There is a searchable archive through March 2000 at http://marc.theaimsgroup.com/?l=twsocket&r=1&w=2 A downloadable archive through May 2000 at http://elists.org/pipermail/twsocket/ and a complete downloadable zip archive at: http://users.swing.be/francois.piette/supportuk.htm#Archives |
Kylix and ICS
Tobias Hermann DZ-Jay 5/31/2001 |
> Can I use ICS with Kylix
Yes, Francois is working on a Kylix version of ICS. You can find the latest beta build on the ICS web site at: http://www.overbyte.be |
Limits of windows
Francois PIETTE francois.piette@overbyte.be 26/12/2005 |
I need 16000 permanent connections
By default W2K and up limit the number of window handle to 10000. As TWSocket use a hidden window per socket, if you don't change that limit, you will not have more than 10000 simultaneous sockets (and even less since the process will use window handles for many other things). I haven't the MSDN reference at hand, you should find it more or less easily. There is a registry key to change to allow more than 10000 handles. You find more explanation on http://support.microsoft.com/kb/327699/en-us |
Local and remote port
Chris Barber 18/08/2001 |
> Can you explain a little more how there can be 2 different port in a tcp connection ?
To begin, every socket has two ports: a local port and a remote port. How these port number get set up depends on whether you are a client or a server (or neither or both, for that matter!). First lets take the case of a client program, such as SMTP (a popular app in this group!). So this client wants to talk to an SMTP server. How does it know what port number to send a message to so that it can get connected? It knows that SMTP servers always listen for client connections on port 25. This is called a "well-known port number". So the client tries to talk to the server by sending to port 25 - this is the client's remote port. What port should the client listen to for the server's response? Not port 25! If it did this it might receive connection attempts from other clients. Instead it listens to a certain port number which is dynamically assigned out of a pool of available port numbers which are not in the range of the well-known ports. Winsock does this when the socket is opened (or somewhere around that time). This is the local port. It might be something like 3000. This port number gets plugged into the source-port field of the messages sent to the server. Now on to the server side. The server sets up a socket to be used to listen for connection requests. This socket must have a local port of 25. When the server responds to the client it will pick up the source port number from the client's message and use this as the destination port (or remote port) of the message sent back to the client. Finally there's one further complication. Servers must be able to handle multiple connections simultaneously. To do this they require more than one socket. Typically there is one socket initially set up and dedicated to listen for client connections. When ever a new connection is accepted a new socket is created. The new socket, dedicated to that new connection, does not have to use the well-known port number. In fact it can not since the original listener socket is still open on port 25. So the new socket sets up with a dynamically assigned local port and its remote port is set according to the source port number found in the original message from the client. The remainder of the client-server conversation is carried out on the new socket using two cross-connected port numbers. When the client discovers that it is connected then it must switch its remote port number to match the new socket that the server opened for it. This allows for multiple connections on the server side and also allows for multiple identical clients operating simultaneously on a single computer - as long as they don't both try to make their connection attempts at the same time. |
Mac address of a NIC
Various 04/06/2001 |
> How can I get the MAC address of a NIC without useing NetBios? Example 1: function GetMACAddress: string; var g : TGUID; i : byte; begin result := ''; CoCreateGUID(g); for i:= 2 to 7 do result := result + IntToHex(g.D4[i], 2); end; Example 2: const INADDR_NONE = $FFFFFFFF; function SendARP( const DestIP : DWord; const SrcIP : DWord; const pMacAddr : Pointer; const PhyAddrLen : PULONG) : DWord; stdcall; external 'IPHLPAPI.DLL' name 'SendARP'; function inet_addr(const cp : PChar) : DWord; stdcall; external 'WS2_32.DLL' name 'inet_addr'; var dwResult : DWord; ulIPAddr : DWord; ulMACAddr : Array [0..5] of Byte; ulAddrLen : ULONG; begin ulIPAddr := inet_addr(PChar('192.168.1.1')); ShowMessage(IntToHex(ulIPAddr,8)); // Ist mal interessant zu sehen if ulIPAddr = INADDR_NONE exit; ulAddrLen := 6; dwResult := SendARP(ulIPAddr,0,@ulMACAddr,@ulAddrLen); ShowMessage('dwResult: '+IntToStr(dwResult)); // if 0, then ok ShowMessage(IntToHex(ulMACAddr[0],2)+':'+ IntToHex(ulMACAddr[1],2)+':'+ IntToHex(ulMACAddr[2],2)+':'+ IntToHex(ulMACAddr[3],2)+':'+ IntToHex(ulMACAddr[4],2)+':'+ IntToHex(ulMACAddr[5],2)); end; Example 3: uses nb30 ; function GetMACAddresses (Pcname: string; MacAddresses: TStrings): integer; const HEAP_ZERO_MEMORY = $8; HEAP_GENERATE_EXCEPTIONS = $4; type TAStat = packed record adapt : nb30.TAdapterStatus ; NameBuff : array [0..30] of TNameBuffer ; end; var NCB: TNCB ; Enum: TLanaEnum ; PASTAT : Pointer ; AST : TAStat ; I: integer ; begin result := -1 ; if NOT Assigned (MacAddresses) then exit ; // sanity test MacAddresses.Clear ; // For machines with multiple network adapters you need to // enumerate the LANA numbers and perform the NCBASTAT // command on each. Even when you have a single network // adapter, it is a good idea to enumerate valid LANA numbers // first and perform the NCBASTAT on one of the valid LANA // numbers. It is considered bad programming to hardcode the // LANA number to 0 (see the comments section below). FillChar(NCB, Sizeof(NCB), 0) ; NCB.ncb_buffer := Pointer (@Enum) ; NCB.ncb_length := SizeOf (Enum) ; NCB.ncb_command := Chr (NCBENUM) ; if NetBios (@NCB) <> Char (NRC_GOODRET) then exit ; for I := 0 to Pred (Ord (Enum.Length)) do begin // The IBM NetBIOS 3.0 specifications defines four basic // NetBIOS environments under the NCBRESET command. Win32 // follows the OS/2 Dynamic Link Routine (DLR) environment. // This means that the first NCB issued by an application // must be a NCBRESET, with the exception of NCBENUM. // The Windows NT implementation differs from the IBM // NetBIOS 3.0 specifications in the NCB_CALLNAME field. FillChar(NCB, Sizeof(NCB), 0); NCB.ncb_command := Chr(NCBRESET); NCB.ncb_lana_num := Enum.lana [I] ; NetBios (@NCB) ; // To get the Media Access Control (MAC) address for an // ethernet adapter programmatically, use the Netbios() // NCBASTAT command and provide a "*" as the name in the // NCB.ncb_CallName field (in a 16-chr string). // NCB.ncb_callname = "* " FillChar(NCB, Sizeof (NCB), 0) ; FillChar(NCB.ncb_callname [0], 16, ' ') ; if PCName = '' then PCName := '*' ; Move (PCName [1], NCB.ncb_callname [0], Length (PCName)); NCB.ncb_command := Chr (NCBASTAT); NCB.ncb_lana_num := Enum.lana [I] ; NCB.ncb_length := Sizeof (AST); PASTAT := HeapAlloc (GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS or HEAP_ZERO_MEMORY, NCB.ncb_length) ; if PASTAT = nil then exit ; NCB.ncb_buffer := PASTAT; if NetBios (@NCB) = Char (NRC_GOODRET) then begin CopyMemory (@AST, NCB.ncb_buffer, SizeOf (AST)) ; with AST.adapt do MacAddresses.Add (Format ('%.2x-%.2x-%.2x-%.2x-%.2x-%.2x', [Ord (adapter_address [0]), Ord (adapter_address [1]), Ord (adapter_address [2]), Ord (adapter_address [3]), Ord (adapter_address [4]), Ord (adapter_address [5])])) ; HeapFree (GetProcessHeap, 0, PASTAT); inc (result) ; end ; end ; end; |
Max size of message queue
Dod dodfr@sky.fr 14/01/2006 |
Windows 2000/XP: There is a limit of 10,000 posted messages per message queue. This limit should be sufficiently large. If your application exceeds the limit, it should be redesigned to avoid consuming so many system resources. To adjust this limit, modify the following registry key.
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Windows/USERPostMessageLimit The minimum acceptable value is 4000. |
Message pump in service application
Arno Garrels arno.garrels@gmx.de 21/04/2003 |
I can't seem to locate where in SvcTCP.pas or TcpCmd.pas the code for handling the message pump is
there is in fact no message pump called in that demo, because socket server runs in the service thread of the Delphi NT Service framework, that has already a working message loop. If you spawn an additional worker thread then you must have a working message pump unless you decide to run ICS in blocking mode. Delphi doc as well as service gurus recommend any task that does not "talk" to the SCM to run in separate worker thread(s). It prevents annoying troubles with the SCM when your app. grows, especially when lengthy jobs have to be done. |
Message pump, what is that
Wilfried Mestdagh wilfried@mestdagh.biz 18/08/2001 |
1.) Windows is an event driven OS. Event driven means that an application in windows not just calls a procedure or function to get input, but instead windows post a message to a window.
For example a key press, or a mouse move, or mouse click is just a message sent to a window. normally it is the active window of an application, but it also can be a hidden window (as in twsocket). Winsock does the same it uses messages to communicate. So each window (a form for example, or a button, or a label) has his message queue. Writing well written programs in windows execute some code and then leave the message pump working. Delphi / BCB does that for you. For example if you click a button the right message is sent to that window, Delphi has arranged the OnClick for you, and yep this is called by that message. If the code exits, then delphi runs the message pump again. this is for example not the case in a dos program. There you have to loop around continuously call functions of do interrupts to check if there is for example a key pressed, or a byte arrived at a serial port. See the difference ? 2.) Gerhard Groenewald gerhardg@db.co.za The point to understand is that Windows is a message driven system. This means that a Windows based application is mostly dormant, waiting for a message to arrive from the operating system. The application has a message loop - an entry point to which Windows will send it its messages. Windows provides a default entry point. In other words, something like (simplified for this purpose)procedure ProcessWindowsMessages(var AnIncomingMessage : TMessage) Case AnIncomingMessage.Msg of WM_LBUTTONDOWN : DealWithLeftMouseButtonDown; WM_LBUTTONUP : DealWithLeftMouseButtonUp; WM_SHOWWINDOW : ShowYourself; Most of these messages pertain to the interaction of the user with your application via components on the window, or moving or resizing the window. Some messages relate to lower level activity (If you move the cursor over a window, Windows continuously sends messages to the window asking it where the cursor is. The window replies to Windows, telling it whether the cursor on the caption, on the border or in the main area of the window. This is how Windows knows, for example, to change the cursor shape when the cursor is on a border) and some messages have their origin in low level drivers that may be activated by interacting, for example with the modem. You can ask Windows to point its entry point for the message procedure to your own one, thereby taking over the task of dealing with incoming messages. The logic typically looks something like this: If the incoming message is a message that I want to handle myself then handle the message else call the default handler Windows Sockets follows this scheme by dispatching messages to a "window" which in this case would be a created socket. If on the low level a disconnect by a remote connection takes place, a message is sent to the socket, if data arrives, a message is sent to the socket. To handle these messages, a message handler is implemented, intercepting windows messages, handling those that pertain to your socket and passing those that do not to the default handler. The message pump is simply a procedure that ensures that when some code has been executed, the next message (if any) in the Windows message queue gets dealt with in the message loop. |
No route to host
Wilfried Mestdagh wilfried@mestdagh.biz 09/03/2001 |
No route to host means you have specified an ip address outside the network and the computer can not find a route to it in his routetable (route print).
|
Port names are not working
Francois Piette francois.piette@overbyte.be 10/02/2005 |
Port names like smtp, pop3 are not working anymore, I have to change it by 25, 110
This may be caused by a virus. In last year version, TWSocket use the "protocol" file to resolve procol names to protocol numbers. A few virus mess the protocol file and protocol names resolution doesn't work anymore and no connection can be established. As this virus is quit frequent, in the current release, I hardcoded the protocol numbers in TWSocket so it works without protocol file being OK. That's what most applications are doing and that's why only TWSocket based applications are affected. So if it is the right diagnostic, you should either repair TCP/IP protocol stack on the affected computer (virus may be gone but the system still affected), or upgrade your application to the latest release. |
Remote printing
Francois PIETTE francois.piette@overbyte.be 16/12/2001 |
> I was wondering whether there was some 'remote print' protocol which might > be implemented in ics and whether I could write a program for the pc which > would receive the data stream intended for the printer and then print it. Yes, there is a standard protocol for doing that and you can implement it using ICS. The protocol is called "Line Printer Daemon Protocol" and is described by RFC1179 |
ResolveIP, what does it return
Holger Lembke holger@hlembke.de 18/08/2001 |
1. Check local computer host name.
2. Check the HOSTS file for a matching address entry. 3. If a DNS server is configured, query it. 4. If no match is found, send a NetBIOS Adapter Status Request to the IP address being queried, and if it responds with a list of NetBIOS names registered for the adapter, parse it for the computer name |
Security
Francois PIETTE francois.piette@overbyte.be 21/04/2003 |
If you need secure login, you should consider using a challenge/response dialog using MD5 unit from ICS. When a client first connect to the server, the server send back some passphrase with some random data. On the same connexion, the client reply with a MD5 hash computed by combining the password and passphrase. When the server receive the hash, it compute the same hash (he knows the password and the passphrase he just send). If hashes matches, then password is OK.
With this dialog, password are never sent over the network, and the hash code is all the time different and session dependant since the server send a random passphrase. MD5 is very strong in this situation. It can be cracked, but would take months to do so, long after the session is finished. And since the hash code is only usable during one session, it gives a very very secure system. |
Server does not accept all simultaneous connections
Haakon Solberg hakos@stud.ntnu.no 21/12/2002 |
When I connect to a server with lots of TWSockets in parralell the server (or TWSocketServer) seems to refuse some of the connections
Winsock has a limit on the number of waiting connections (listen queue) which is 5. So if more than 5 connection requests come in the same very short interval, some will be refused. This is how winsock works. Winsock call this parameter a connection backlog, which defaults to 5. More info on this can be found in section 4.14 of http://tangentsoft.net/wskfaq/advanced.html. The limit of 5 waiting connections seems only to be valid for Windows 2000 Professional (possibly this value could be changed). On Windows 2000 Server the backlog is set to 200. In TWSocket.pas, the WSocket_listen function takes a backlog parameter with a value for 5. I changed this value to 200, compiled and linked a new version of the appserver, and re-tested on a Windows 2000 Server. This time the server could handle 200-215 consecutive requests without problems. According to the winsock FAQ, the backlog parameter value should not be set too high because of the risk of malicious attacks/flooding. Still, maybe this parameter could become a property of the TAppServer / TWSocketServer component in the future... |
Server on win9x refuse to have lots of serialized connections
Wilfried Mestdagh wilfried@mestdagh.biz 21/12/2002 |
The linger options (witch is default ON) will try the system do a graceful shutdown when a socket closes, in a way so that data is arrived on the other side before the connection actually break. If you turn this option OFF, then the OS does not hold the socket in TIME_WAIT after close so that resources are freed immediately. A disadvantage of setting this option to OFF could be that the chance is bigger that after the server close in busy networks some of the data never reach the client Some test results (thanks to Andy): wsLingerOff - the demo runs indefinitely wsLingerNoSet - the demo runs indefinitely wsLingerOn - the demo halts after around 65-75 Get calls with "Error 10055 in function Listen. No buffer space available" |
Size of a console program
Francois Piette francois.piette@overbyte.be 20/07/2004 |
How to avoid that Forms unit is included in a console application?
Add NOFORMS to your project defines. |
Sniffer tcp/ip
Angus Robertson - Magenta 21/07/2001 |
> ISniffer appears to be Win95/98 only, has anyone found a sniffer that
> will work with NT4/W2K? To answer my own question, WinPcap is a free C sniffer that works with all 32-bit windows platforms, from http://netgroup-serv.polito.it/winpcap/, there's a Delphi header conversion and demo program at http://home1.stofanet.dk/nitezhifter/contents/delphicomp.htm that includes one of the files from ISniffer with Francois Piette corrections. There is also an excellent Analyzer application that uses WinPcap which parses all the tcp/ip packets including various protocols like http, smtp, etc. I wish I had it years ago for developing winsock stuff, you can see exactly what is being sent and received without the complication of a proxy. |
SSL Socket support
Wilfried Mestdagh wilfried@mestdagh.biz 28/01/2003 |
> Can anyone tell me if SSL protocol is supported with
> TWSocket or will it be in the near future. Yes, pre-release code is already available to contributors. It contains the base component TSslWSocket and two demos: one SSL client (can act as a HTTPS client) and one HTTPS server. To participate to the SSL effort, send an email to François Piette to say how much you wants to give to finance the development. Visit also the official SSL page on www.overbyte.be . Result effort will be donated to ICS community one year after the product is released to contributors. Each contributor will have immediate access to the code. There is also a website and a mailing list dedicated to the contributors. Check official SSL page . |
Stress tool and firewalls
Dod dodfr@sky.fr 14/01/2006 |
What should I take care if I use a personnal Firewall (firewall installed on the machine you are running your application on) ?
- Personal firewalls (Kerio, Tiny, Outpost, Norton Internet Security...) greatly reduce network and socket performances, so if you want to benchmark or do some stress test, get rid of your firewall temporally. - If you get crashes and your application do heavy socket usage (and you are of course sure your are 100% bug free :-), try to disable your firewall. For example, tested on Win2K SP4, Kerio personal Firewall 2.1.5 do not support more than 16384 followed connections without reboot, it produce a BSOD in fwdrv.sys. - Note : Disabling firewall using its GUI interface options usually do not disable the network driver of the firewall at all, it just disable the filtering rules so slowness and crashes may still appear unless you completely uninstall the firewall ! - Note 2 : If you don't want to uninstall/reinstall all the firewall stuff (because you did a lot of specific rules and don't want recreate them all), try to find the firewall driver (for example Kerio uses fwdrv.sys) in the /system32/drivers, rename it and reboot system, this permit real disabling without uninstall. Then you can rename it again later to its original name. |
Timeout time of TIME_WAIT
Gerhard Knapp prometheus@aon.at 21/12/2002 |
This setting determines the length of time that a connection will stay in the TIME_WAIT state before being closed. The default is 240 seconds which on a busy server will limit the maximum connections to around 200/sec. Reducing this setting will increase the maximum connection limit. Create a new DWORD value, or modify the existing value, called "TcpTimedWaitDelay" and set it to 30 decimal. Exit your registry, you may need to restart or log out of Windows for the change to take effect. Registry Settings System Key: |
Upper limit of sockets
Wilfried Mestdagh wilfried@mestdagh.biz 1 mar 2003 |
I want to write a server, what is the max amount of clients in ICS
This is not limited for ICS, but limited in operating system. On windows9x the max amount is 100, but the OS has a lot in use also. On NT or W2K it is limited by the amount of the non-paged memory pool, because the design of winsock. The non paged memory pool is always in RAM and cannot be swapped to disk by the virtual memory manager. The non paged memory pool has a maximum size of 1/8 the size of the physical RAM, and has an upper limit of 128 MB in NT and 256 MB in W2K. This means that you hit the upper limit when you have in NT 1 GB, and on W2K 2 GB RAM installed. The amount of memory needed by winsock is around 2 KB. Sending and receiving uses overlapped I/O thus also uses non paged memory and are in blocks of 4 KB. So if a socket is sending / receiving then you you need minimum 10 KB per socket. An idle connection will consume 2 KB, and a connection that only send or receive 6 KB. If you have very high speed data on a fast LAN you need even more memory. And of course there may be other applications that use the non paged pool also. |
Using a lot of sockets
Rich richard@e-fprint.com 16/12/2001 |
> My application fails when using a lot of sockets
When I refer to win 9x I actually mean 95, 95OSR/2, 98, 98SE and Millennium Edition (ME) All versions of windows impose a limit to the number of sockets you can open. On 95 this limit was around 100, Winsock 2 lowered this limit to around 30 and as a result a lot of applications like NukeNabber that opened lots of ports or applications that accepted lots of inbound connections started to fail. This applies to a lesser degree to Windows NT and 2000 and probably to XP too. Before you can deal with this you need to know a few things. For all the current MS operating systems you can fix this problem with a simple registry change, however there is a reason for this limit. Firstly each socket uses a chunk of resources, on a system with low memory you will quickly run out of resources if you open hundreds of sockets. There are also speed issues as processor time is used by Winsock to handle the sockets, this can also seriously degrade the stability of the system. As a side effect it limits the damage of applications that may maliciously try to open a large number of sockets for various uses. And finally, with 9X, its done to make running servers hard. The 9x series of OS’s was never designed to be used for servers, in fact anyone thinking of running a server on these system should make sure the OS is patched properly, updated to Winsock 2 at least and preferably upgraded to at least Win 98. According to the MS view of the world, all servers should run on NT, this is fine for those who have NT but not for the majority of us who either cant afford it or don't want it. Fixing this issue is, as already stated, quite easy. Before you do it you need to work out a few things. Because of the potential to adversely effect the system you mustn't’t just change these keys to a ridiculously high number, you should only change it to what you need. A safe bet is to take the 30 socket limit from Winsock 2, add 10 for safety and then add exactly the number you need. E.G. if I expect around 200 simultaneous users then the socket limit would be moved upwards to 240. When tried on a test machine (Pentium 200MMX, 64Mb) 98 SE started to have problems after about 400 connections with connection times increased from a few mS to about 1S. Into the 1000 range connections started to take up to 5S and at 1500 the system crashed from resource starvation. To apply this patch you need to use the registry editor. If you are unfamiliar with this program, don't try. There is the potential to do a lot of damage to the OS in the registry if you alter or delete the wrong thing. You should, if possible, back up at least the registry or the whole system. The registry lives in two files in the windows directory, USER.DAT and SYSTEM.DAT, they are normally hidden and set as system files. If you have to restore them you will need to drop to DOS. If you are planning on applying this patch automatically within your application you really should back up these files, or at least the key involved. Run Regedit by typing ‘regedit’ in the run box. Depending on the version of windows you need to find the following keys : Win9x : HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP You will need to find the value called MAXCONNECTIONS. It may not actually exists, in which case you need to add it, its a string value. Set the value to the number you worked out earlier and no more. For NT /W2k: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters You are looking for the MAXUSERPORT value this time, it *should* already be there, if not, add it. The values is a DWORD and should be set to the number you worked out. Be sure to take into account any other services you are running when you set this. You will need to restart for these changes to take effect. For safety’s sake, you can export the keys you are altering before you make the change, then if things don't work out, a quick double click on the .reg file you exported and a reboot restores your system. |
Wake up a computer
Francois PIETTE francois.piette@overbyte.be 22/09/2001 |
> I would like to be able to wake a PC over the LAN.
> It's a special packet that you send to a computer > that's turned off. > Then the PC will turn it self on if Wake-On-Lan is enabled > The format is: [MAC address repeated 8 times] > FFFFFFFFFFFF,00E0189022B4,00E0189022B4,00E0189022B4, ... You can't because wake up over the LAN is not TCP/IP. You have to directly talk to the NDIS driver to send this special packet. |
Winsock error 10038
Francois Piette francois.piette@overbyte.be 20/04/2004 |
I have a TWSocketServer app that gets intermittent 10038 exceptions during it's operation (socket operation on a non-socket). They occur during the
It could also result from an error not related at all to socket programming. If your program inadvertently call CloseHandle with an incorrect argument, it could close the socket if the wrong argument has the value of a socket handle. |
Winsock error 10035
Wilfried Mestdagh wilfried@mestdagh.biz 21/12/2002 |
Sometimes I get a 10035 when I call LastError
The 10035 is something as 'try again', and TWSocket take this into account. So you don't have to worry and safely ignore it. But you normally don't need to call the LastError as winsock error code (if any) is already given in the event's his arguments. |