Receiving XML file from http in C - c

I need to somehow enable XML file transfer in the way that some machine, which generates a XML file sends the XML file through HTTP to another client. This other client would be based on C, receive the XML file and process it.
Is this possible in any way? I only found results for sending XML files to a HTTP server using some URL. I guess I'd have to implement my own HTTP server in my C application? Any ideas?

maybe you can use libcurl
here is a http POST example: http://curl.haxx.se/libcurl/c/http-post.html
on the receiving computer has to be a listening socket. here is a socket example: http://www.codeproject.com/Articles/586000/Networking-and-Socket-programming-tutorial-in-C
this socket takes the incoming data for later processing...

Related

How to implement http2 streaming client?

I was looking to create a http2 streaming client in C which is able to connect to server, create stream and keep listening for messages from server on that stream without cancelling the stream unless explicitly cancelled or network issue.
I was trying to implement it via libcurl but seems there is no such support in libcurl, at best what I can do is just make a request with curl and not have a timeout. Then curl will just sit there waiting for the transfer to start or complete, until the server does that. And when one transfer is done, the client can just issue another request and go back to waiting...
But I just want to maintain the stream rather than issuing another request to server after receiving message.
I don't want to use GRPC which provides similar functionality but along with it comes lots of complexity of libs and platform dependencies to be resolved.
Is there any other C based library or any http2 stream reference which I should have a look at?

Use of fork command in C in a chat application

I have a problem in this question, please anyone can guide me
Communication between client and server in C ubantu:
Client will send message and address of another client to server and server will forward that message to that client. Other client will reply to server in a same format and server will forward that message to specified client.
I have to use fork command in this Question.
How I will send address to server and message together?
I don't think you should use fork in this case. You can keep an array containing your client's sockets with a unique ID, which can be the address, and forward the message you receive from a client to the one with the ID specified in the original message. The select() system call can be useful when monitoring an array of file descriptors.

How to get browser's socket for sendfile() in fastcgi ?? (in C)

I'm trying to file upload and download in fastcgi.
To use sendfile() I need the web server's open socket to the client (browser).
fastcgi doesn't pass it to me (I don't think).
I'm clueless on how to get the browser's socket descriptor.
I'm also open to another approach without a redirect or opening a new connection.
help is appreciated
You don't get a socket to the browser in FastCGI. The only socket you get directly is connected to the web server, and it's expecting FastCGI data frames, not just raw data.
The most typical solution for file downloads is the X-Sendfile header, which directs the web server to spit out a file (probably using something like sendfile() internally) instead of your response. It was introduced by Lighttpd, is supported natively by nginx, and is supported by Apache via mod_xsendfile.
Remember that a socket and a file is mostly handled the same, so you can use the standard output file descriptor as output "socket" instead of a real socket:
#include <unistd.h>
int in_fd = open(...);
sendfile(STDOUT_FILENO, in_fd, NULL, length_of_file);

sending file from client to http server in c programming

i have to write c program in which the file can be transfer to server , we have the http url link for that.what we have to do for sending and receiving file/data.
Actually i have to send file to http server , on calling url the file will be transfer.it's like that when user click on send the text file will transfer to that server. help so some light ..any link that i can get help .thanking you
From reading the comments, it sounds like you're going in the direction of using sockets directly. Don't do that. Use an HTTP client library. The basic HTTP protocol is simple enough that the sockets approach is workable for a rudimentary client, but you won't support features like HTTP keepalives, proxy servers, encryption (https), HTTP/1.1, compression, chunked encoding, or 100 continue without completely reinventing the wheel.
Use libcURL. When writing in C, uploading a file to an HTTP server is only a few dozen lines of code, including boilerplate.

Get info for Common Log Format from socket in C

I want to create a log file for my webserver written in C under UNIX.
The logfile should be formatted according to Common Log Format, but I don't know how to get the ident and authuser from the connecting socket.
Is there a simple way to get these from the socket?
User name is not an attribute of socket - you need to get it from HTTP request, so sockets API can't help you on this.

Resources