Thread: scanning a network

  1. #1
    Registered User
    Join Date
    Oct 2005

    scanning a network

    I made a little socket serverthat works (tested with telnet) and now I am starting to code myself a client to interact with the server.

    The problem:

    multiple pc can host multiple servers with diffirent ports. The client will have to scan the network to search for servers and build a list of server where one is choosen at random.

    Now scanning the network ( - takes forever.

    for(i = 1 ; i < 255  ; i++){
    		serv_addr.sin_addr.s_addr = inet_addr(address);
    		for (y = MINPORT ; y <= MAXPORT ;y++){
    			serv_addr.sin_port = htons(y);
    			if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(struct sockaddr))  < 0){
    				if (DEBUG){printf("%s:%d no connection\n",address,y);}/*No server found*/
    				if (DEBUG){printf("w0000000000t %s:%d got connection\n",address,y);}
    				sockfd = socket(AF_INET, SOCK_STREAM, 0);	
    There has to be a better way to do this I hope. Please help.

  2. #2
    Unregistered User
    Join Date
    Sep 2005
    it would be best to use raw sockets and send the connection attempt manually. The connect function can take forever to timeout. This isn't an easy thing to do, though there are plenty of open source things for linux that will do this. There is one in particular, but I can't quite remember the name. try doing a google search for something like "raw sockets syn packet"

  3. #3
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Still in the egg

    Nmap is a powerful open source port scanner. I don't know but it may have a network scannig option.

    Hope helps...

  4. #4
    Registered User
    Join Date
    Oct 2005
    I am now testing the raw sockets thing. Hope it works. Also I think I just might change my server to respond a broadcast and then sending his ip and port to the client that send the broardcast.

    Will see if nmap can help.

    Ty to you will let you know how it works out

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 3D Network Analysis Tool
    By durban in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 11-08-2005, 06:33 PM
  2. Need help with easy Network setup
    By the dead tree in forum Tech Board
    Replies: 9
    Last Post: 04-08-2005, 07:44 PM
  3. network problems
    By lucy in forum Tech Board
    Replies: 6
    Last Post: 01-01-2003, 03:33 PM
  4. Got Network?
    By RoD in forum A Brief History of
    Replies: 21
    Last Post: 11-21-2002, 03:44 PM
  5. WinXP Network Connections pop-up
    By DavidP in forum Tech Board
    Replies: 1
    Last Post: 10-02-2002, 05:36 PM