From: | Jonathan Adamczewski |
Date: | 1 Oct 2001 at 03:19:56 |
Subject: | Re: [amiga-c] Speedup recognition of ip:port |
Do several connects simultaneously (start several threads). I'm not a
master with sockets, but you should be able to set the timeout value as
well...
jonathan.
---
No sleep till bedtime.
On 30 Sep 2001, Herbert Klackl wrote:
> Hi,
>
>
> I'm trying to process a file which consists of lines with IP-addresses and
> portnumber.
>
> All I want to do is to check whether each IP-address:Port is available or not.
>
> So, what I do is that for each line
> a) I create a socket
> b) fill a sockaddr_in structure with the appropriate data
> c) connect to destination IP:Port
> e) check whether it was successfull or not
> f) close the socket
> like in the following lines:
>
> --- cut ---
> /* create socket for connection with servent */
> socketfd = socket(AF_INET, SOCK_STREAM, 0);
>
> /* fill sockaddr_in struct for connection */
> memset(&(dest_servent), 0x00, sizeof(dest_servent));
> dest_servent.sin_family = AF_INET;
> dest_servent.sin_port = htons(dest_servent_port);
> dest_servent.sin_addr.s_addr = inet_addr(dest_servent_ip);
>
> /* try to connect to servent */
> retval = connect(socketfd, (struct sockaddr*)&dest_servent,
> sizeof(struct sockaddr));
>
> /* check whether successfull or not */
> if (retval == -1) {
> printf("...failed!\n");
> } else {
> printf("...ok!\n");
> }
>
> /* close socket */
> CloseSocket(socketfd);
> --- cut ---
>
> The upper code works (of course the loop and reading of the data is missing).
>
> However the problem is that - if a destination can not be reached - it takes
> ages (5 to 30+ sec) until i get a response from connect.
>
> Does anyone know a faster/more secure way to solve this problem?
> After all, it is unacceptable for the user if he has to wait several minutes
> to get about 4 connections from several dozens (or even hundreds) of lines.
>
> BTW: I'm using the AmiTCP-SDK from Aminet for the networking routines. AFAIK
> Miami and Genesis are AmiTCP compatible and therefore I can be sure to reach
> the most user.
>
>
>
> Bye Herby
>
>
>
> »Messages sent to this list are archived and placed on Aminet.«
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Pinpoint the right security solution for your company- Learn how to add 128- bit encryption and to authenticate your web site with VeriSign's FREE guide!
http://us.click.yahoo.com/yQix2C/33_CAA/yigFAA/dpFolB/TM
---------------------------------------------------------------------~->
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/