* * *

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

Jonvy

  • New member
  • *
  • Posts: 13
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

  • Full Member
  • ***
  • Posts: 147
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: 13
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

  • Full Member
  • ***
  • Posts: 147
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: 6126
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 »
I might not give the answer that you want me to.. Peter Green 1969

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6241
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: 6126
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.
I might not give the answer that you want me to.. Peter Green 1969

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6241
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: 6126
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 »
I might not give the answer that you want me to.. Peter Green 1969

Jonvy

  • New member
  • *
  • Posts: 13
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: 5080
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

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus