C :: Send HTTP With Sockets

Apr 9, 2013

I'm connecting to my website through sockets, like this:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include <string.h>
int main(int argc, char *argv[]) {
WSADATA wsadata;
if (WSAStartup(MAKEWORD(2,2), &wsadata) == -1)

[Code]...

I want to send GET to a certain web page. How can I do that?

View 2 Replies


ADVERTISEMENT

Visual C++ :: Use Windows Sockets To Send Email?

Jan 26, 2013

I have struggled to send email from my MFC applications using severl methods:

1) http via my server - works but limited
2) M$ Outlook automation - works but not easily interchangeable between machines
3) Windows Sockets - available information simply too complicated
4) Purchase an ActiveX control - I hate black box solutions and am too cheap

I have looked at P. J. Naughter's class
CPJNSMTPConnection v2.99
An MFC class to encapsulate the SMTP protocol
[URL]

This approach requires the implementation of OpenSSL which turns out to be nothing short of a nightmare to install (so I never got it to run). I am looking for an example of an application that utilizes SMTP via Windows sockets api.

View 6 Replies View Related

C# :: How To Send Message To Multiple Sockets In List Object

Oct 7, 2012

Have tried to track down the delay? Which function takes that long? Have you printed some logs or measured the time of the functions? No I am not sure how to do that! I debugged it but i didn't see any difference! I definitely think its the logic in the receive code that's "inefficient" what do you think about that? Do you think there's a more efficient way of receiving messages and sending them? Because what I am doing is receiving one then calling send and sending that message out to all users then receiving another one then calling send and sending it out to all users and repeating that process till all the messages are sent, both methods are using a loop to send to all users. DO you think i should receive all messages then send them all out at once? or is that less efficient?

View 4 Replies View Related

C :: Unable To Send Binary Data Via HTTP Response

Feb 7, 2013

I'm trying to send some binary data, such as an animated gif, via an HTTP response for a simple web server.

I am having issues having the browser close the connection after receipt of the data.

I create the header such as:

"HTTP/1.1 200 OK
Content-Length: <file size>
Content-Type: <file type>
<binary data>"

This is stored in a malloc'ed char *. To add the binary data I'm using fread: fread(request + strlen(request), 1, size, fp)

I then write 'total' bits via connfd:

write(connfd, request, total)
where total = strlen(headerRequest) + size + 3 (for ending
).

The writing seems to be okay however the image doesn't load and the browser still seems to be waiting for data.

If I added "Connection: close" to the header and closed connfd myself the page loads fine. Obviously, for efficiency purposes, I'd rather only close connfd once read() returns 0.

The header creation code is below:

======= Code:

/* Try to get file */
strcat(cwd, file);
if(endsWith (cwd, ".html") || endsWith(cwd, ".htm")) {
strcpy(fileType, "text/html");
binary = 0;
} else if (endsWith(cwd, ".txt")) {
strcpy(fileType, "text/plain");
binary = 0;

[Code]...

View 7 Replies View Related

C :: Send To Another Host Via HTTP Post And Existing XML File

Oct 6, 2014

My user requires that I add function to an already working C server that will send to another host via http post and existing xml file. I have googled and found C# and C++ on how to do this but nothing using C. Where do I start?

View 1 Replies View Related

C :: HTTP Packet Generation And Send / Receive Via Socket

Dec 26, 2014

I have Build code for sending/receiving TCP Traffic over c Socket . Now I want t add HTTP Protocol to it .

After searching out on google ,one method I found which is by GET method to send a query to a server like google.com and request a page .

But ,Suppose I saved a HTML page in my directory how can I send HTTP packet via client/server in socket using this HTML page .

View 4 Replies View Related

C/C++ :: HTTP Packet Generation And Send / Receive Via Socket

Dec 27, 2014

I have code for sending/receiving TCP traffic over C socket. Now I want to add HTTP protocol to it. After searching the web, one method I found which is by GET method to send a query to a server like google.com and request a page.

But, suppose I saved a HTML page in my directory how can I send HTTP packet via client/server in socket using this HTML page.

Server side code:

sockfd = socket(AF_INET, SOCK_STREAM, 0);
bind(sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
listen(sockfd,5);
newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr,&clilen);
while (1)

[Code] .....

View 1 Replies View Related

C :: Sockets Using Poll

Jul 13, 2013

Until recently I have been using select() to wait for activity on file descriptors, however this seems less efficient than poll. I rewrote the program using poll:

Server:

Code:

#include <stdio.h>#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
#include <sys/types.h>
}

[code].....

View 11 Replies View Related

C :: Sending A Packet Over Sockets

Oct 30, 2013

I have a socket connection already set up, my thing is what would be the best way to send a packet through sockets? My teacher wants us to convert the packet to bits first before we send it. I think he wants something like this:

Code:
struct packet{

int header
int message
int flag

}clientpacket; m

My question is how do we covert this to bits, before sending it. One of my friends said we can create a char[] array the size of the struct as a buffer. will memcpy() change the struct to bits if I copy it to the buffer?

this is how is suppose to look in bits for the header field/column.

Field : header
Field size(bits): 8
data format: Unsigned int
value example: 1
Value in bits: 0000 0001

I am confused, I think I send a structure over the socket but I did not convert it to bits before I sent it .

View 13 Replies View Related

C :: Sending Numbers Through Sockets

Nov 1, 2013

I want to write a program(s) so that the client sits and waits for a scanf to receive an int, then send to server, server then receives the int, processes it, then goes back to sit and wait for new input. to start with, where do i start! server side, or client side? and also what order do i have to go in my program before the loop to set up the socket, and listen? and then what gets looped to keep the connection open and wait for new receive?

View 4 Replies View Related

C# :: Created A Simple Basic Program That Uses Sockets

Feb 22, 2012

I have created a simple basic program that uses sockets but it can only handle one connection, how do I make it so it handles multiple connections?

Server code:

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
}

[code]...

View 5 Replies View Related

C++ :: Execute HTTP Command From Code

Jun 17, 2014

I'm working on a project that's got a lot of moving parts, from feedback from a position sensor to real-time video editing. The script that runs the sensor is in C++, and the API for the video editing software (vMIX) is executed with HTTP protocol. I'm hoping to use that C++ script to control the video software (as some of the editing is dependent on particular feedback from the sensor), and wanted to see how to execute a HTTP command from a C++ script.

View 3 Replies View Related

C/C++ :: What HTTP Command Allow Using Integer Variable

Jan 24, 2014

How can I use an integer variable in a http command example:

int num, canal;
for (num =0, num < 10, num++){
canal = num;
system( "wget http:'/'/192.168.3.4/channel.cgi?channel= canal");
}

View 3 Replies View Related

C++ :: HTTP Response Receive Using Socket

May 18, 2014

I make a simple c++ http post request using socket and it is working fine. But how to get only the message of the response. Here is my receive code:

char buffer[1028];
recv(socket, buffer, sizeof(buffer), 0);
printf("%s", buffer);

Then here is the response that the http send back.

HTTP/1.1 200 OK
Data: Mon, 19 May 2014 12:46:36 GMT
Server: Apache/2.4.9 (Win32) OpenSSL/0.9.8y PHP/5.4.27
X-Powered-By: PHP/5.4.27
Coneten-Length: 28
Content-Type: text/html

All done! Do some stuff now. So what I want to try is get 3 things in this response and put them to string vector but how to do this. What I need is to parse the response and the 200 OK, 28 and All done! Do some stuff now. then put them to string vector.

expected result

response[0] = 200 OK;
response[1] = 28
response[2] = All done! Do some stuff now

View 2 Replies View Related

C# :: SOAP Messaging In WebSevice Using HTTP

Apr 11, 2014

I am new to SOAP and i have already done message based communication in WindowsFromApplication where both can send and receive SoapEnvalope using TCP.

But Now i am facing a problem where one Side is in WindowsFormApplication and other is in ASP.NET and i want to communicate in save way. (creating a Listeners on both application and send envelops) here is my code, i have confusions that how to make a receiver and secondly should i add a web service (asmx) in my asp.net project or not? and i want to communicate using HTTP

here is my code.

SoapEnvalopeReceiver receiver = new SoapEnvalopeReceiver();
receiver.throwEnvalopeEvent += receiver_throwEnvalopeEvent;
Uri listeningURL = new Uri(textBoxReceiveAt.Text);
EndpointReference erpReceive = new EndpointReference(listeningURL);
SoapReceivers.Add(erpReceive, receiver);
labelStatus.Text = "Connected";
labelStatus.Visible = true;

or I don't know how can make Asp.net application a listener and form Application too .....

View 2 Replies View Related

C++ :: HTTP POST Request - Connection Failure

Apr 22, 2014

I have issues with this i am new to winsock. so i was learning to use winsock for http POST request

Compiles correctly, but doesnt connect i get the error "Connection Failure" what do you think can be wrong

My code goes like this:

Code: #define WIN32_LEAN_AND_MEAN
#include "stdafx.h"
#include <cstdio>
#include <cstdlib>
#include <Winsock2.h>

[Code] .....

View 1 Replies View Related

C++ :: Testing HTTP Headers - For Loop And Strings

Jun 23, 2014

I am testing HTTP Headers and I have an strange problem. When I get the response of the server, it is the correct one the first time. If I use a for loop to send more than one request and get more than one response, this response seems to be overlapped with the previous ones. To a better explanation of the problem I attach the code I am using and the output generated:

TCPSocket.h
-----------
#ifndef _TCPSOCKET_H_
#define _TCPSOCKET_H_
class TCPSocket {
private:
int localSocket;

[Code] .....

So, a bigger loop, a bigger the response of the server. However, I know the response of the server is always the same.

View 3 Replies View Related

C/C++ :: Create App That Uploads A File Using HTTP Request

Oct 18, 2014

I need to create C++ app that uploads a file using http request. I have the following php file on my server:

<?php
$uploaddir = '/var/www/uploaded/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {

[Code] .....

Now, i know the general idea of how its supposed to be done but I just cant get it right. Either my "post" message is wrong all the time or some library is not working properly. Im not even including the code for the application because I have 5 projects, each with different approach and none of them is working.

View 4 Replies View Related

Visual C++ :: HTTP Flood Code Ported To Bot Source?

May 6, 2013

I am stress testing my webservers and I need to code or port a C++ HTTP GET flood onto this C++ bot sourcecode. I believe I will need GetTickCount so I can specify the duration of the flood as well. I already have the C++ HTTP Flood .cpp and .h files but have no clue how to put it together onto this source. This will be easier to do over Teamviewer as I'm already using C++ 6.0 and have been with no issues.

View 14 Replies View Related

Visual C++ :: Change HTTP Request Server Response - Proxy?

Nov 19, 2013

Is there anyway to make when browser request some file from server than browser to load another file. Example:

I open [URL] ....

So now the browser send http request to load image [URL] ....

so when browser want to load that image to load this image [URL] ....

I do this now with [URL] ....

I think this can be done with Wininet.dll and WinHTTP.dll

View 3 Replies View Related

C :: Using COM Ports To Send Files Between Two PCs

Dec 2, 2014

My first time programming sth in Network. I have to use C to send a file to another PC, well COM port are useful but I didn't find how to refer to the address of my destination.

View 4 Replies View Related

C :: How To Send A String To C# Application

Apr 1, 2014

i developed 2programm that the first one is in C and the second one is in c#.and now i have to send some string text from c to c#.how can i do that in c ?

View 8 Replies View Related

C :: Send Data Packet

Mar 6, 2015

how to send datapackets. When we send a data packet from device to another, say I have a "string". How Do I send it? Are data sent as a hex or binary number?If so do i first convert the "string" into hex or binary and then send it over the communication medium(say UART)??

I have two hex numbers to be sent using the UART, do i wrap it in some specific form and send it and retrieve it on the other side?Say if I have a data structure, in that case how do i send it? Sending data packets is very cruicial in an embedded system.

View 3 Replies View Related

C++ ::  Send Binary Data Over TCP/IP

Sep 3, 2014

I am writing a client-server program in C++ using C libraries. The server listens for a connection and when one is found, it is supposed to send a binary file(an image in my case) to the client. The server is sending the binary file perfectly after opening it and reading its contents into a buffer that is dynamically allocated in the SERVER file.

The problem begins when the client file is supposed to recv() the file, I do not know how I can allocate a buffer big enough for the file to be received. I know how to use malloc() and new, I prefer malloc() for executable size customization. Assuming the file being sent is 11000 bytes(note that this is an assumption and the client can not know the file size because the file size is dynamically generated by server).

How can the client generate a dynamically allocated buffer big enough to hold 11000 bytes?
OR
How can the client store the data in a buffer using recv() without knowing the file size.

Below is part of the code that does the send()'ing and recv()'ing.

SERVER

FILE *img = fopen("img.jpg", "rb");
fseek(img, 0, SEEK_END);
unsigned long filesize = ftell(img);
char *buffer = (char*)malloc(sizeof(char)*filesize);
rewind(img);
// store read data into buffer

[Code] ....

This outputs all the binary code perfectly but it is a bug because it can't be written to a file. Is there a way to dynamically increase the buffer until all filesize is received? Certainly, buffer needs to be dynamically allocated or program crashes ...

Also one more thing, when I telnet the server from command line, telnet displays all the output perfectly as well

Maybe telnet is storing data into a buffer behind the scenes, if so, how?

View 9 Replies View Related

C++ :: Send Info To PHP Webpage?

Jul 3, 2014

I was wondering if there was a way for me to send information, say a username and password, to a webpage via a c++ function. I was unsure how exactly to word it, but I did attempt to google it. Here is an example of what I mean.

App starts -> goes to "Https://www.my-site.com/?user=$username&password=$password" -> username/password is valid -> logs them in on desktop app

I do not know much about php, but I am assuming the ?user=$username is setting a variable, correct? I am familiar with sockets, but it seems using the above method, this could be possible without sockets, would it?

Important part:

That is the method that minecraft uses to login players, the question here is what function could I start to send the desktop app to the webpage.

EDIT:: After looking a little more I find that it is probably not possible without sockets, which is fine; however I don't know how to do it still, I would prefer to not use external libraries, such as Curl.

View 3 Replies View Related

C/C++ :: Send And Recv In Winsock2

Aug 4, 2014

so im just getting into network programming and im trying to make a chat server and client so i can send and receive messages. I have written both a chat and a client, with no error reporting (i know, i know). But the message that comes through on the server side is "hiiinaovH+". Ive represented this as well as i can but really they are non alphabetic symbols coming through.

client code:

#include <iostream>
#include <winsock2.h>
int main()
{

[Code]....

View 13 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved