Thread: Network output

  1. #1
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121

    Network output

    Ok all i want to know how to do is get data from my network card no matter what it may be, i want it. HOW?

    In C there are certain commands that you can use to send data to COM1, LPT1 ect how to i accept data from eth1 and eth2?
    -- Will you show me how to c++?

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    You need some form of socket library (e.g. Winsock if you're on Win32). There's no standard way to do this, sadly.

    Generally, you'll need to create a socket and bind it to the port you want to listen on.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  3. #3
    C++ Newbie
    Join Date
    Nov 2005
    Posts
    49
    Is it possible to do through asm? Like, how are the socket libraries implemented in the first place?

  4. #4
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    You'll have to link to any existing socket libraries; most compilers come with built-in libraries for sockets on the host operating system. If you're on Windows you can just use winsock.h and link to the win32 library, for example.

    Frost Drake, I think there should be no need at all to use non-portable super-obfuscated ASM code.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    Quote Originally Posted by Frost Drake
    Is it possible to do through asm? Like, how are the socket libraries implemented in the first place?
    My question here: why do you want to do that?

    There isn't going to be a truly platform-independent solution -- the best you can do is some socket library that is implemented on all the major operating systems.

    Even if you bypass Winsock, you'd still be tied to Windows because you'd be communicating with the device drivers, and those are platform dependent. In fact the lower down you get the MORE platform dependent your code will become, not less.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  6. #6
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121
    I want to extract and see raw packet info, but to do that im sure i have to find out how to
    get information from the source or in this case the network card
    -- Will you show me how to c++?

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Or just use this perhaps?
    http://www.winpcap.org/default.htm
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    I want to extract and see raw packet info, but to do that im sure i have to find out how to get information from the source or in this case the network card
    Here’s why you have to use Winsock or something like it:

    - Windows prevents user mode programs from directly reading or writing bytes to hardware. In order to do that, you have to write a kernel mode driver.

    - Hardware manufacturers do not publish the details of how to communicate directly with their hardware/firmware. They supply a driver that communicates with their particular hardware and with Windows. So, even if you know how to write drivers, you don’t usually have the inside information that you need.

    The driver is like a translator/interpreter. It can translate between the standard Windows/Winsock data and the format/data needed by the proprietary hardware.

    The advantage to all of this “extra” complication is that your program will work with any network card in any (Windows) computer. In the old DOS days, each application had it’s own driver… You had to get a printer driver for your spreadsheet and another printer driver for your word processor, etc. It was a real mess. If your application didn’t have a driver for your new printer, you were out of luck. (Well, not totally out of luck because most printers had an Epson emulation mode.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code output...
    By roaan in forum C Programming
    Replies: 6
    Last Post: 07-03-2009, 02:22 AM
  2. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  3. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 03:29 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Network Location
    By (TNT) in forum Windows Programming
    Replies: 2
    Last Post: 03-23-2002, 04:05 AM