If I have a Windows computer and a Mac computer or a Linux computer, is there a recommended library way to transfer a file between them that doesn't involve FTP, passwords, etc.
For example:
Computer #1: Windows 7 with a local ip of 192.168.1.5
Computer #2: Mac Lion with a local ip of 192.168.1.9
Is there a known peer-to-peer file transfer library out there for C and/or C++ or is this a common method for this using an established library or something I'm not aware of.
you can use the library libcurl.
There is no login and password prompts. just give the login and the password in the curl config with the function curl_easy_setopt and all the work will done by the libcurl
Related
i use a Mac from programming in C through Xcode. The version is macOS Mojave 10.14.
The code i'm using has a client who asks for time and a server who replies giving him the current time printed through a UDP connection.
I use client 127.0.0.1 to launch client.
The code works perfectly on linux, but on Mac it just starts loading and never stop.
These are the codes.
UDP Client
https://github.com/lufth/UDPClientServer/blob/master/clientUDP
UDP Server
https://github.com/lufth/UDPClientServer/blob/master/serverUDP
In Mac OS, there are several security features in place which is different from a linux machine. Maybe you could check to ensure if your program is not hindered by these 2 security features
Code Signing
Sandbox
For the sandbox, you may check if your UDP client / server executable is attempting to read/write to a location which is outside its allowed locations.
Alternatively, you may also try to run your server and client as root too
sudo java client.java 1111
The address_len parameter to recvfrom is an in/out parameter, but in your server you are passing a pointer to an uninitialized variable, len.
(Also, it is probably a good idea to give your C source files names ending in .c.)
I am dealing with socket programming with C language and Xcode. I can open socket, server and client. I need to learn my machine's Mac address and then, I will send Arp request for server machine.
Almost all examples had been written for linux. I need to solve it in Mac OS.
Currently, I am using these codes with opening two projects and they are able to communicate.
https://www.geeksforgeeks.org/socket-programming-cc/
Could you give some example or information about this problem?
I am using the socket module in python to send commands to my raspberry pi to turn GPIO pins on and of.
I am switching to C, where I will use winsock.h and winsock2.h to create the server on my PC and sys/socket.h to create a client on the raspberry pi.
Is it possible to establish a connection between these two different libraries?
I only want to create a socket, bind, send and recv. No other operations.
I recommend you to check this documentation, there are some examples for a Windows Server / Client connection:
https://learn.microsoft.com/en-us/windows/win32/winsock/getting-started-with-winsock
For Linux you need to do some adaptations as you might know or you have already implemented, I did the same for 2 desktop applications to send data from a Linux PC (client) to a Windows PC (server). As mentioned in the comments it doesn't matter the devices while they are in the same network and follow the TCP/IP protocol.
I was able to do this even connected through a VPN. Unfortunatelly I can not share the code. But I developed this communication based on the documentation from the link above.
I hope it helps. Actually if you want to use Python in the raspberry Pi there is also a python built-in package that you could use: https://docs.python.org/3/library/socket.html
And you can use the code from the link above in Windows. It should be straighforward.
I am trying to figure out from C code in linux if an interface is configured as static or uses dhcp.
I know I can open and parse the /etc/network/interfaces file, but I would prefer something cleaner, like the function getifaddrs() that I use to get the IP address and the mask. Because what if the interface is configured as dhcp in /etc/network/interfaces file but later on the user changes it to static from the command line? I would get a wrong answer.
Is there any way for asking the kernel about the static/dhcp current state of an interface?
The kernel (the Linux part of e.g. GNU/Linux) doesn't decide, it doesn't (and shouldn't) care, it just gets told which network addresses go with which interfaces by whatever configuration system the OS is using. OpenWRT's not GNU, it operates differently
DHCP IP address adquisition is usually managed by distribution scripts or network manager services configured by host. At low level they could use dhclient daemon...
In Debian, dhclient daemon creates the file
/run/dhclient.${interface}.pid
so, you could test when the interface is being set by dhclient.
In not fully managed network environment you should also read that file and test if the process ID is still alive.
I have an embedded system that is programed in C. I need to do the equivalent to the DOS command Telnet. The idea is to test if the remote host is up and running.
I would like to have some orientation here like:
Open source project that I can use as a guide line (C language)
Some documentation on what the Telnet command does (so I can
implement my own)
Thanks
Update: Thank you for your valuable comments
My system connects to a host via GPRS/Ethernet/dial up/Wifi (one of them). As a developer I check if the host is ok by using my windows laptop (with a Dial up modem, GPRS modem or whatever is needed) and running Telnet like this:
telnet 192.168.0.1 8000
(non real values)
If the host is ok I got the clean screen, otherwise I got an error. That's what I need to do in code, to be able to determine if the host is up and running by using a sort of DOS telnet client command in C.
This is done once, just to check communications, after this test is cleared the real info should be sent.