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


ADVERTISEMENT

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 :: 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 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

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







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