Recent

Author Topic: Socket addrinfo structure  (Read 7558 times)

Alex Cones

  • Jr. Member
  • **
  • Posts: 73
    • FLSoft
Socket addrinfo structure
« on: September 03, 2011, 08:01:52 pm »
Hello!

I`m learning a sockets for now, and trying to do something with them. But I can`t find a addinfo structure in winsock module.

I`m using this mans for learning:

Creating a Socket for the Server
addrinfo structure

Help, please.
To beer or not to beer?
_____________________
I`m terribly sorry for my Anglish. :)

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Socket addrinfo structure
« Reply #1 on: September 03, 2011, 09:03:07 pm »
Then just convert yourself the structure:

uses ctypes;

{$packrecords c}

type
  addrinfo = record
    ai_flags: cint;
    ai_family: cint;
    ai_socktype: cint;
    ai_protocol: cint;
    ai_addrlen: csize_t;
    ai_canonname: PChar;
    ai_addr: Psockaddr;
    ai_next: Paddrinfo;
  end;
  Paddrinfo = ^addrinfo;
  ADDRINFOA = addrinfo;
  PADDRINFOA = Paddrinfo;

and similarly for whatever else you need. You might also want to make a patch for this unit so that this gets included in future fpc releases. Note that there is also a unit winsock2, not sure if this type should go to both.

Alex Cones

  • Jr. Member
  • **
  • Posts: 73
    • FLSoft
Re: Socket addrinfo structure
« Reply #2 on: September 04, 2011, 08:00:35 am »
Ok. After all, where I need to place my "patch"?
« Last Edit: September 04, 2011, 08:20:55 am by Alex Cones »
To beer or not to beer?
_____________________
I`m terribly sorry for my Anglish. :)

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Socket addrinfo structure
« Reply #3 on: September 04, 2011, 08:39:04 am »
In the bug tracker.

Alex Cones

  • Jr. Member
  • **
  • Posts: 73
    • FLSoft
Re: Socket addrinfo structure
« Reply #4 on: September 04, 2011, 08:49:48 am »
Ok.

But I can`t define the addrinfo structure:

Code: [Select]
Type

  TAddrInfo = Record
   ai_flags      : Integer;
   ai_family     : Integer;
   ai_socktype   : Integer;
   ai_protocol   : Integer;
   ai_addrlen    : Size_t;
   ai_canonname  : PChar;
   ai_addr       : PSockAddr;
   ai_next       : PAddrInfo;
  End;

  PAddrInfo : ^AddrInfo;

Quote
UNTNetTypes.pas(21,29) Error: Identifier not found "PAddrInfo"
UNTNetTypes.pas(21,29) Error: Error in type definition
UNTNetTypes.pas(26,1) Error: Forward type not resolved "AddrInfo"
UNTNetTypes.pas(26,1) Fatal: There were 3 errors compiling module, stopping
To beer or not to beer?
_____________________
I`m terribly sorry for my Anglish. :)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Socket addrinfo structure
« Reply #5 on: September 04, 2011, 08:53:39 am »
Quote
PAddrInfo = ^TAddrInfo;
and put it before TAddrInfo definition

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Socket addrinfo structure
« Reply #6 on: September 06, 2011, 09:57:56 am »
(1) these are for winsock2 not unit winsock
(2) these are XP+
(3) Try unit jwaws2tcpip, it has some newer header translations.

 

TinyPortal © 2005-2018