Programming :: Non Blocking Socket Send
Mar 7, 2011
Been trying all sorts of different things to implement a non-blocking send on a TCP server socket.As I kill the client, the server keeps blocking on the send no matter what. Am I missing something? Any other way to do that without involving any additional thread?
View 4 Replies
ADVERTISEMENT
Dec 25, 2010
I have a device that is working on modbus protocol andI have written a small program(with block TCP read method ) to read its registers via modbus protocol.my program is working very well but except those times that I unplug the Ethernet cable or turning off the modbus gateway during programs work.at this time my program stops on recv system call (if it reach this system call exacly when I unplug Ethernet cable or turning off the modbus gateway during programs work).I changed my source to work in nonblock TCP method, at this time with the same situation my program does not stop/block on recv system call but after pluging back the Ethernet cable or resuming the connectivity situation back it reads data incorrectly .this is my code:Quote:
#define DEBUG
#include <fcntl.h>
#include <string.h>
[code]...
View 5 Replies
View Related
Mar 31, 2010
My question is quite simple:What are type of applications where socket in blocking mode can be used ?
And where non-blocking mode to be used ??
TCP is blocking by default.
View 2 Replies
View Related
Jan 24, 2011
Has anyone had an issue with gdb not being able to send a UDP msg across a socket?
I have ComponentA sending a msg to ComponentB utilizing gdb. ComponentB gets the msg. ComponentB sends a msg to ComponentC. ComponentC does stuff to the msg and sends a msg back to ComponentB using gdb.
ComponentB never seems to receive the 2nd message.
If I don't use gdb the messages Tx and Rx without an issue.
I'm flying blind without gdb to figure out a different bug.
View 3 Replies
View Related
Nov 20, 2008
how can i send a text file from server to client? the problem is, i dont know how to send those two file to the client ( center node)
View 1 Replies
View Related
Jul 23, 2010
I am currently doing a research on video transmission over wireless LAN. I tend to transmit my offline file (xx.svc) from server to client.It may sound stupid (since I have a very little knowledge about c programming and raw socket), but my biggest challenges is that when I want to write the file to the buffer, how actually to define/include the file at the programming coding? where I need to locate the file? Is it at the same folder with my c programming, or somewhere in the linuxinclude folder?
Can anyone just give a simple example on how to include a file and write it into a buffer before send it through raw socket.
View 14 Replies
View Related
Jun 22, 2009
this is my client and server. I can receive text file. but I can't send other type of file like PDF,Docx,Odt
View 11 Replies
View Related
Jan 2, 2009
I'm trying implement a small server for a university work, my server is creating, binding and listening but it don't accept any connection, these are the files I'm using in server:
Code:
// Definition of the Socket class
#ifndef SOCKET_H
#define SOCKET_H
#include <sys/types.h>
code....
I've made a client just for test it, but no ones run well, the server is always returning -1 when accept is called!!
What should I do to send and receive messages in this server??
View 3 Replies
View Related
Mar 8, 2011
iam just trying to connect to server which accepts one client and server will read(blocking operation) infinitely, but After closing the client socket the server "read operation" is returning zero and "errno variable(in errno.h)" value is also zero. how can i detect whether a client socket is closed/active..?
client.c
Serv_Addr.sin_family = AF_INET;
Serv_Addr.sin_addr.s_addr = inet_addr("127.0.0.1");
Serv_Addr.sin_port = htons(26553);
if( 0 > connect (Serv_Fds,&Serv_Addr,sizeof(Serv_Addr)) )
{
perror("connect");
return 0;
[Code]....
View 3 Replies
View Related
Oct 27, 2010
I need to write program for non blocking socket connections.I have made extensive research but could only get to non blocking READ or WRITE after the connection is established. run the program do a series of tasks (ex: counter printing time on screen) if there is request for connection, connect send or receive data.
View 1 Replies
View Related
Mar 23, 2010
For system calls, is blocking or non-blocking default in C? Simple question, just am not seeing the answer super quickly.
View 4 Replies
View Related
Mar 27, 2011
I'm running Ubuntu 10.10 64bit, and I'm a newbie when it comes to networking.
My issue is that there seems to be a socket bound to a port blocking MongoDB from accessing it's usual port 27017. The strange thing that it was working just fine until recently and I can't figure out what I did to screw things up... I can make it use a different port but the reason why it can't bind to the default port and why I can't fix it is really bothering me. I've tried rebooting the machine even with nothing else running when I try to run Mongo is still blocked giving the following message:
Code:
ropes@ropes:~/mongodb-linux-x86_64-1.8.0/bin$ ./mongod
./mongod --help for help and startup options
Sun Mar 27 14:08:14 [initandlisten] MongoDB starting : pid=2718 port=27017 dbpath=/data/db/ 64-bit
[Code]....
View 5 Replies
View Related
Jul 6, 2010
i'm writing a simple program of client socket program. Here below is the code sample which i'm writing...
Code:
//tcp_client.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include<string.h>
#include<stdlib.h>
[Code].....
the above code works fine.if we copmile and run ./a.exe 192.xx.xx.xxx 1111 and press enter it works fine..everytime it asks "Please enter the message: " and if give that will be displayed in server. but my problem is i dont want to print everytime "Please enter the message: " i just want to feed some words one by one to the socket.
View 4 Replies
View Related
Mar 30, 2009
im getting that error in my code for some reason. I compiled my code, and when i try to run this server it throws me an error on my call to setsocketopt(). The only way it can reach that part of my loop is if it succeeds when it calls sock() so I dont understand why the error says its an operation on a non-socket. Im just trying to set up a server to pass messages from a client to it a viceversa. Here is the code:
Code:
int main()
{
int socket_fd, new_socket_fd, k;
struct addrinfo hints, *server_info, *p;
struct sockaddr_storage peer_address;
code....
View 7 Replies
View Related
Nov 20, 2008
how can i send an array of string to the client from the server side?
View 2 Replies
View Related
Feb 23, 2009
I am currently trying to get a B.A.T.M.A.N mesh network up and running. the thing uses UDP port 4305 for broadcasting to nearby nodes and it seems this port is closed or used by something else.
now i have tried to open this port with commands like
Code:
iptables -A INPUT -p udp --dport 4305 -j ACCEPT
iptables -A OUTPUT -p udp --dport 4305 -j ACCEPT
it still gives me the same error saying the socket cannot connect.any way for me to scan that udp port, see what is blocking it and open the thing up ?
View 4 Replies
View Related
Oct 1, 2010
I am created one udp socket. i want to send the data(bytes) to another PC.i need to send 614400 bytes of data. while sending it saying error like" message is too long ". so what is the maximum possible data can i send from a socket?
View 3 Replies
View Related
Nov 10, 2010
I'm trying to create a PF_PACKET socket and send a frame to another host, I know the destination's mac address and interface index, and I want to use my own protocol no., so I defined a PROTONO as 0x2323, here's the code of sender
Code:
#define MYPTNO 0x2323
int main(int argc, char **argv)
{
intsockfd;
//struct sockaddr_inservaddr;
struct sockaddr_ll servaddr, bindaddr;
[Code]...
View 1 Replies
View Related
Apr 5, 2011
Code: # traceroute -I 69.12.32.2 Note: the -i and -I options were exchangedfor compability with LBL traceroute Use -I for ICMP, and -i <ifname> to specify the interface name unable to create ICMP send socket: Permission denied Note that the command was done as root. This worked in 11.3.
And yes, it works without the "-I". But it should work with the "-I". One shouldn't have to boot into Windows, just to run "tracert" there.
View 9 Replies
View Related
Mar 8, 2011
I have a server listening on incoming client connections. Once the client establishes SSL connection with the server, the server waits on read() from the client. Only Client can disconnect the connection. I want to have a timer in the server program to wait for x secs after read() and then disconnect the Client connection.
View 3 Replies
View Related
May 16, 2011
i have a server program which accept multiple client connection and am using polling. like every 2 secs it will look to client whether any data is received after it binded. i have used setitimer but there is runtime error i got.. the server accept all client connection but doesn't execute any msg which client sent.
#include<stdio.h>
#include<stdlib.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netdb.h>
#include<unistd.h>
#include<pthread.h>
#include<string.h>
[Code]....
View 1 Replies
View Related
May 11, 2011
i have problem in socket programming, while displaying received message in file,i got a problem... i cant able to write it in the file.... this is the code....
Code:
/* tcpserver.c */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
[Code]....
now my problem is run time error i can able to create file but i cant able to write file....log.txt contain nothing.... as here i have give sample code... dont say not initialising function and all.... i have initialised , please only see func1() - my problem is only not able to write msg which i got received from the client..
View 2 Replies
View Related
Aug 25, 2010
how to use socket programming in order to implement chatting feature
View 5 Replies
View Related
Dec 5, 2010
When sending data over the socket, the sending socket includes 0x00 after each sent byte. I wonder how this can be avoided -- I just want to transfer the data in the tx_buffer as it is.
# ./serv &
[1] 6895
# ./EUG 127.0.0.1
EUG: Data to be transmitted: 0x35 0x32 0x30 0xff 0x03 0x31
EUG: Data - #Bytes transmitted: 6
./serv: Here is the message: '5'
[Code]...
View 3 Replies
View Related
Mar 28, 2011
Is it possible to swap a client ip and port ? This is what I am trying to do. Let say you have Comp1 and Comp2 And you have Server between them. My goal is to get Comp1 and Comp2 know each others IP So Comp1 connects to server And server stores comp1's IP In a text file or other place And Comp2 connect to server And server also stores his info And then both comp1 and comp2 dowload the tex file And use the info on it.
View 9 Replies
View Related
Jan 30, 2011
How can we build a packet using C?we have a structure called sockaddr_in which is use to for IPv4,so that we can define address,port and etc in this way:
Code:
struct sockaddr_in sock;
sock.sin_family=AF_INET;
[code]...
View 5 Replies
View Related
Nov 11, 2010
This is my main question:Quote: In raw socket sniffing: how do I copy data from a structure into a char[] or pointer? My problem: I started doing some raw socket programming in OpenWRT (I'm a newbie) for research. It's been a long time since the last time I programmed in C, so here's my newbie question/problem.
I'm receiving packets and using an .h file with the structures to get the information of each 802.11 packet in monitor mode (attached to this post).My (simple) goal is to get the Tx MAC Address. No luck. This is my "read the prism header" function:
Code:
ParsePrismHeader(unsigned char *packet,int len)
{
wlan_header *wlan;ieee_802_11_header *i802;u_int16_t eth_type;
unsigned char *mac;unsigned char *mac2;
wlan = (wlan_header *)packet;
i802 = (ieee_802_11_header *)(packet + wlan->msglen);
[Code]...
View 3 Replies
View Related
Mar 16, 2010
I am looking to be able to connect to an IRC server in a C program. I have followed some instructions from an old book I have however it doesn't seem to be working. I've tried connecting to localhost on my ssh port and it still doesn't want to work. This is what I have so far as a piece of skeleton test code:
Code:
#include<sys/types.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/socket.h>
#include<unistd.h>
#include<netinet/in.h>
#include<arpa/inet.h>
[Code]....
View 1 Replies
View Related
Jul 21, 2010
Where is the perl module for programming with sockets?
View 4 Replies
View Related
Jan 15, 2010
I have currently had the need to go back to basic socket programming, and implemented a simple udp packet sender. But I realized I needed to be able to select which network interface to send the packets from.
The reason is so that one of the interfaces has vlan tagging, and I need my UDP packets to be accordingly vlan tagged. For example, one of the interfaces is eth1.200.
View 2 Replies
View Related