Recent

Author Topic: Can BaseUnix works for Windows system?  (Read 3691 times)

Jonvy

  • New Member
  • *
  • Posts: 28
Can BaseUnix works for Windows system?
« on: May 28, 2018, 05:58:54 am »
I'm writing a new program wants to use fPFD_SET function defined in baseunix.pp.
I'm using Lazarus on Windows7 32 system.
But when I'm compile the program, it gives the Message:Fatal:Cannot find BaseUnix used by Unit1 of the Project Inspector.

I'm checking:Unit BaseUnix in folder: \Lazarus\fpc\3.0.0\source\rtl\unix\baseunix.pp

Is it mean I canot use it under Windows system?

Or I should add the path to compiler? If so where should I add this path? Can someone tell me the menu?

Thanks!

HeavyUser

  • Sr. Member
  • ****
  • Posts: 310
Re: Can BaseUnix works for Windows system?
« Reply #1 on: May 28, 2018, 07:04:46 am »
I'm writing a new program wants to use fPFD_SET function defined in baseunix.pp.
I'm using Lazarus on Windows7 32 system.
But when I'm compile the program, it gives the Message:Fatal:Cannot find BaseUnix used by Unit1 of the Project Inspector.

I'm checking:Unit BaseUnix in folder: \Lazarus\fpc\3.0.0\source\rtl\unix\baseunix.pp

Is it mean I canot use it under Windows system?
correct.
Or I should add the path to compiler? If so where should I add this path? Can someone tell me the menu?
No, tells us what you want to do and we will find the appropriate reference for your task in windows.

Jonvy

  • New Member
  • *
  • Posts: 28
Re: Can BaseUnix works for Windows system?
« Reply #2 on: May 28, 2018, 07:33:24 am »
I'm making a program use fpSocket to creat a socket and use fpRecv to receive data.
Now the problem is if no data in socket, the problem will get no resonse.
If there is data in socket, it works fine, I can get data with fpRecv.

So I want to use fpSelect to judge if there is data in socket.
But fpSelect will use BaseUnix.
 

HeavyUser

  • Sr. Member
  • ****
  • Posts: 310
Re: Can BaseUnix works for Windows system?
« Reply #3 on: May 28, 2018, 09:52:16 am »
I'm sorry I use indy for my socket needs. I'll leave this to someone with more experience on the field.

Thaddy

  • Hero Member
  • *****
  • Posts: 10704
Re: Can BaseUnix works for Windows system?
« Reply #4 on: May 28, 2018, 10:12:50 am »
If it is standard Berkeley socket functionality it should work on Windows as well as Linux. If it is an extension, then no. I have to look that up. You should probably not use baseunix, but winsock.
« Last Edit: May 28, 2018, 10:29:05 am by Thaddy »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9085
  • FPC developer.
Re: Can BaseUnix works for Windows system?
« Reply #5 on: May 28, 2018, 11:59:28 am »
Windows usually prefers asynchronous sockets, and the select() way of working is different (also, the way to work with fdsets is different, the windows sets are not bitfields but arrays with elements).

This is why fpselect is not in unit sockets, it is not part of the cross platform sockets abstraction.

Thaddy

  • Hero Member
  • *****
  • Posts: 10704
Re: Can BaseUnix works for Windows system?
« Reply #6 on: May 28, 2018, 12:34:36 pm »
Windows usually prefers asynchronous sockets, and the select() way of working is different (also, the way to work with fdsets is different, the windows sets are not bitfields but arrays with elements).

This is why fpselect is not in unit sockets, it is not part of the cross platform sockets abstraction.
Standard Berkeley socket functionality need not be abstracted. What makes you think so? AFAIK Linux is closer to the standard with not many exemptions, but Windows has a complete implementation with extensions.
Since the reverse is here applicable, it should work with winsock too. Otherwise there's an issue with fpc's winsock.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9085
  • FPC developer.
Re: Can BaseUnix works for Windows system?
« Reply #7 on: May 28, 2018, 02:15:38 pm »
Standard Berkeley socket functionality need not be abstracted.

What is standard berkeley sockets? Standard as in what is standarized for TCP/IP in general (which afaik doesn't contain select), or the subset commonly supported by unices (the posix sockets?)

Contrary to Unix, Windows NT was threaded from the start, and therefore has different programming models in certain cases.

Quote
What makes you think so? AFAIK Linux is closer to the standard with not many exemptions, but Windows has a complete implementation with extensions.

Well, as said, most unices use bitfields, and have different non standarized calls for larger numbers of connections (incompatible though, like kqueue/epoll)  Afaik Windows has arrays of thandles as TFDSet, and a low maximum number of items in a set (64 in winsock?)

Since the reverse is here applicable, it should work with winsock too. Otherwise there's an issue with fpc's winsock.
[/quote]

Older winsock v1 was totally defunct in this functionality, which was still dominant in 2003 when this decision was made.

Afaik Ales (Almindor) already kicked the tires of that bounderies when he worked on lnet in 2007,2008 using v2. But I do remember him having troubles with all these kind of ioctl like functionality. Most of it didn't work, and he went more a ifdef model.

But that is all iirc and old news.

Of course the sane question is why messing with this at all, and not simply using Indy or synapse.

Thaddy

  • Hero Member
  • *****
  • Posts: 10704
Re: Can BaseUnix works for Windows system?
« Reply #8 on: May 28, 2018, 02:45:41 pm »
You should also look at winsock2. That was my mistake.
Of course there is nothing against using synapse for blocking mode. Windows supports *both* blocking and non-blocking mode since NT4, it just made the asynchronous model easier to use.
The implementation level can differ but the protocol level should be handled correctly in all but the non-standard cases. (Otherwise networking in general or if you like the internet would not work between Windows and Linux or anything else:the protocol stack should be covered and it usually is).

I am still not quite sure this should not simply work. I will examine winsock2 however.
« Last Edit: May 28, 2018, 02:47:13 pm by Thaddy »

Jonvy

  • New Member
  • *
  • Posts: 28
Re: Can BaseUnix works for Windows system?
« Reply #9 on: May 30, 2018, 04:27:49 am »
Thanks for your suggestion, I changed to winsock, it works.

For the question why I don't use Indy is,my application is very simple, just receive data from machine ethernet port
and send data to printer's ethernet port.
For Indy, it looks too strong, the pdf manual has 4876 pages, and it has too many controls, I don't know where to start learning and which control to use, it confused me. So I would rather like to use simple connect, send,receive socket functions.

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: Can BaseUnix works for Windows system?
« Reply #10 on: May 30, 2018, 04:48:28 am »
I don't know where to start learning and which control to use, it confused me.
From your description I would focus on the TTCPClient and TTCPServer controls they are the simple sockets nothing more. For farther help first decide what is the communication protocol you need to use and search for the appropriate client or server in extremely short TCP is the base protocol http, nntp, ftp etc are using TCP as their underline communication layer. That should get you started if ever wanted to delve in to it.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

tonathiu

  • Newbie
  • Posts: 1
Re: Can BaseUnix works for Windows system?
« Reply #11 on: January 16, 2021, 11:13:43 am »
Quote
Quote
Is it mean I canot use it under Windows system?
correct.

Hello guys sorry to jump here, I also  had problems reading the Unix unit. I am using Windows lazarus environment. Can you explain to me why Different units are only working in different OS?  In this case why Unix unit does not identfy in Windows? thx


[Edited to fix quoting.]
« Last Edit: January 16, 2021, 11:25:00 am by trev »

PascalDragon

  • Hero Member
  • *****
  • Posts: 2751
  • Compiler Developer
Re: Can BaseUnix works for Windows system?
« Reply #12 on: January 16, 2021, 11:37:16 am »
Hello guys sorry to jump here, I also  had problems reading the Unix unit. I am using Windows lazarus environment. Can you explain to me why Different units are only working in different OS?  In this case why Unix unit does not identfy in Windows? thx

Why would you even expect a unit named Unix to work in Windows? You don't expect the Windows unit to work on Linux or macOS either, do you? Or one of the Amiga specific units? (*) Yes, FPC is cross platform, but that does not mean that every unit is available everywhere. That's why you have to use ifdef and such when working with platform specific functionality.

(*) The only exception to this is the Dos unit, but only because it's essentially the SysUtils unit from TP times and does not contain OS specific functionality.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2073
Re: Can BaseUnix works for Windows system?
« Reply #13 on: January 16, 2021, 01:28:25 pm »
Why would you even expect a unit named Unix to work in Windows? You don't expect the Windows unit to work on Linux or macOS either, do you? Or one of the Amiga specific units? (*) Yes, FPC is cross platform, but that does not mean that every unit is available everywhere. That's why you have to use ifdef and such when working with platform specific functionality.

(*) The only exception to this is the Dos unit, but only because it's essentially the SysUtils unit from TP times and does not contain OS specific functionality.

I think that there's a bit of unfortunate terminology here though, in that "Windows" could be taken as a generic term representing any windowing user interface (i.e. including Gnome etc. on Linux). There's also people who like referring to "at the DOS prompt" in a "terminal emulator", when what they really mean is "in a shell session".

Considering OP's original question, my recollection is that at least some variants of Winsock did support a select() function with a timeout. So it's reasonable for him to think that there should be bit-manipulation functions/macros available, even if he's mistaken in thinking that the Unix, BaseUnix etc. units are applicable to anything other than unix-based OSes (let's leave unix-like subsystems on Windows NT etc. out of this).

He must also appreciate that the various /options/ available in variants of the Berkeley Sockets API are very much operating-system specific. So for example on Linux you need to set a specific option to indicate that (example taken from memory here) you intend to use a UDP broadcast, while on Windows no such option exists since the facility is enabled as standard.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9085
  • FPC developer.
Re: Can BaseUnix works for Windows system?
« Reply #14 on: January 16, 2021, 09:00:16 pm »
I think that there's a bit of unfortunate terminology here though, in that "Windows" could be taken as a generic term representing any windowing user interface (i.e. including Gnome etc. on Linux).

Rarely heard, if ever.

Quote
There's also people who like referring to "at the DOS prompt" in a "terminal emulator", when what they really mean is "in a shell session".

Any form of text-only interface, yes. Still, I don't think it is our job to give general IT education and terminology.

So that reduces the question to "could the user have found out that the unit is only meant for one (group of) target(s)?".

There is the RTL layout, and notes etc in the docs, but maybe something more prominent is needed. I think that is more constructive than discussing alternative interpretations of unit names. (specially as the interpretations might be depending on similarities in terminologies in other languages)

Quote
Considering OP's original question, my recollection is that at least some variants of Winsock did support a select() function with a timeout.

Afaik C code too needs modifications to cross the *nix-windows gap, even if you use select.

I can also remember that the winsock version of select had some limitations (at least Ales). Anyway, if you want to pursue this, it is bet to look at the LNET code.
 
Quote
He must also appreciate that the various /options/ available in variants of the Berkeley Sockets API are very much operating-system specific. So for example on Linux you need to set a specific option to indicate that (example taken from memory here) you intend to use a UDP broadcast, while on Windows no such option exists since the facility is enabled as standard.

I think as a beginner you are better of with a socket suite like Indy. If you want to go further, study it.



 

TinyPortal © 2005-2018