MAC und IP aus Socketverbindung bekommen?

Für allgemeine Fragen zur Programmierung mit PureBasic.
gonimaus
Beiträge: 27
Registriert: 26.09.2004 14:21
Wohnort: Günzburg

MAC und IP aus Socketverbindung bekommen?

Beitrag von gonimaus »

Hallo,
hat jemand eine Idee, wie ich aus einer Socketverbindung mit OpenNetworkConnection am Server die MAC-Adresse und die IP-Adresse des Clients herbekomme? Im TCP/IP Stream müßten doch diese Informationen enthalten sein?!
Hintergrund ist, daß ich mit einem Tool in Abhängigkeit von der MAC-Adresse bestimmte Daten an den Client schicken muß.

Danke schon mal im Voraus
Benutzeravatar
Lars
Beiträge: 347
Registriert: 31.08.2004 23:53
Wohnort: Shanghai
Kontaktdaten:

Beitrag von Lars »

Windows:

Code: Alles auswählen

    ClientIPTemp.IPType
    Length = SizeOf(IPType)
    Result = getpeername_(NetworkClientID(), @ClientIPTemp.IPType, @Length)
    If Result = 0
      ClientIP.s = StrU(ClientIPTemp\IP[0], #Byte) + "." + StrU(ClientIPTemp\IP[1], #Byte) + "."
      ClientIP + StrU(ClientIPTemp\IP[2], #Byte) + "." + StrU(ClientIPTemp\IP[3], #Byte)
    Else
      ClientIP.s = "[Not aviable]"
    EndIf
Lars
The only problem with troubleshooting is, that sometimes the trouble shoots back.
P4 2,6Ghz, 512MB RAM, GeForce 6200, WinXP Pro SP2, PB V3.94
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Beitrag von ts-soft »

@Lars
kannste vielleicht die Structure auch noch Posten. thx im voraus :allright:
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
gonimaus
Beiträge: 27
Registriert: 26.09.2004 14:21
Wohnort: Günzburg

Beitrag von gonimaus »

Wow,
das ging ja schnell.

Bin gerade am Testen.
Hier die Struktur, die ich bereits gefunden habe.

Code: Alles auswählen

    Structure IPType 
      Reserved.w 
      Port.w 
      StructureUnion 
        IPLong.l 
        IP.b[4] 
      EndStructureUnion 
      Zeros.l[2] 
    EndStructure 
Danke schon mal
Gruß Gonimaus
Benutzeravatar
Lars
Beiträge: 347
Registriert: 31.08.2004 23:53
Wohnort: Shanghai
Kontaktdaten:

Beitrag von Lars »

gonimaus hat geschrieben:Hier die Struktur, die ich bereits gefunden habe.
Sorry, die hatte ich dann wohl vergessen :)
Lars
The only problem with troubleshooting is, that sometimes the trouble shoots back.
P4 2,6Ghz, 512MB RAM, GeForce 6200, WinXP Pro SP2, PB V3.94
Antworten