Programming :: Socket Programming Using Php - Swap A Client Ip And Port?

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


ADVERTISEMENT

Programming :: Tcp Client Socket : Get Own Port Number?

Oct 1, 2010

I am working with simple tcp client to establish connection to sockaddr_in servAddress and send data segment:

...
connect(sockfd,&servAddr,sizeof(servAddr)) < 0)
send(sockfd, pkt, pktLen, 0);
close(sockfd);
...

Elementary... Here's the tricky part: next i have to handle user level ack the server is sending to "client"... To do that i have to open server socket on the same port number the system assigned to my client socket before. How can i get it ( in user level code)?

View 2 Replies View Related

Programming :: Socket Programming - Detect Whether A Client Socket Is Closed / Active?

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

Programming :: Timer In Socket Programming - Wait For X Sec After Read() And Then Disconnect The Client Connection

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

Programming :: Socket And Timer Programming - Server Doesn't Execute Any Msg Which Client Sent

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

Programming :: Chat Socket Between Client And Server

Mar 17, 2011

I want to built a Chat Program (based on Socket connection) between client and server. I use the GTK+ &GLADE graphic tool. Can you send me the code for this program or any material to learn. Also, I want to know how to show the input to text view (in GTK+&Glade).

View 3 Replies View Related

Programming :: How Could Server Detect Closed Client Socket Using TCP And C++

Aug 6, 2010

Reading some examples on net and copying some codes I was able to build a (frankstein) server that accept connection from one client and receive and send messages to it. The big problem that shows up is that I don't know when client disconnects from my server.

I've been looking for a solution, but no success. I'd read about SO_KEEPALIVE option (which could solve my problem), but I don't know how to use it (how to check the value of it).

I can't use ping because the server (machine) could be running, but not the client (software).

Anyone knows a good tutorial or how to (for beginners like me xD) of TcpIp sockets using c/c++ and how to detect when a client disconnect?

I don't know sockets very well.

View 6 Replies View Related

Programming :: Remote Client Mac Address On Socket Descriptor?

Dec 14, 2010

I want to get the connected client MAC Address after accept() call. I can get the IP address of the client but i don't know how to get the client MAC Address in my this programme. Here I am Posting my Code.

#include<stdio.h>
#include<sys/socket.h>
#include<sys/types.h>

[code]....

View 10 Replies View Related

Networking :: Socket Programming - Connect To Port Y On IP X With Telnet

Sep 16, 2010

I have a customer who is complaining that they can connect to prt y on IP x with telnet. They are seeing the following:

telnet x.x.x.x y
Trying x.x.x.x...
Connected to x.x.x.x.
Escape character is '^]'.

after some time the connection of course times out. Connection closed by foreign host. There is no telnet service running on this port so they cannot do anything, but they are complaining tht the fact that telnet "connects" is a security risk. I am having difficulty explaining why they are able to connect with telnet. I know it has to do with the socket layer API in Linux but I am having difficulty explaining this sufficiently. I also can't just say "this is the way linux works" to them. I am looking through "UNIX Network Programming" by W.

View 3 Replies View Related

Programming :: Raw UDP Socket And ICMP Destination (Port) Unreachable?

Oct 26, 2009

I'm using a single raw socket to read UDP packets from local test network with 1024 ports. Each UDP src and dest port is unique and I need access to IP and UDP header fields. I can stream and process data (in and out) at 100 mbps in linux-rt kernel with very low jitter < 250 usec, 10 usec nominal.

I'd like to prevent kernel from issuing ICMP port unreachable errors back to the sending host, however, I don't want to create 1024 vanilla UDP sockets and bind to each one because of resource constraints. Currently, I'm using iptables to drop the outbound port unreachable messages. Does anyone know of a way (programmatic using C code) to prevent the ICMP unreachable traffic? Perhaps an IOCTL or socket option? I also tried changing /proc/sys/net/ipv4/icmp_ratelimit but that seemed to have no effect. By default the ratemask is set for dest unreachables and a variety of ratelimit values did not change any behavior that I could see.

View 5 Replies View Related

Programming :: Fetch The Remote Client Mac Address On Socket Descriptor?

Dec 14, 2010

I have written one simple code which is posted here. i want to fetch the Mac Address on socket descriptor which is returned after accept () call.

Code:-

#include<stdio.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>

[code].....

View 1 Replies View Related

Programming :: Bind A PF_PACKET Socket To A Specific Port Number?

Sep 26, 2010

I am trying to create a socket to listen for a bootp response so I am using a PF_PACKET socket so that I get the response based on my mac. My problem is that I don't want to hear all traffic (as I do now) so would like to use a specific port number and bind to it.

View 1 Replies View Related

Programming :: Bind The Listening Socket To A Paricular Ip Address And Port?

Jun 26, 2011

I am learning network prgramming in linux in c,and try to build a server and in this server I want to bind the listening socket to a paricular Ip address and port.Bind function is showing error,I did not want to use wild card. Here is the code.

#include<stdio.h>
#include<sys/socket.h>
#include<strings.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<string.h>

[Code]...

View 2 Replies View Related

Programming :: Socket Programming While Displaying Received Message In File

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

Programming :: Use Socket Programming In Order To Implement Chatting Feature?

Aug 25, 2010

how to use socket programming in order to implement chatting feature

View 5 Replies View Related

General :: Socket Programming - Feed Some Words One By One To The Socket

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

Programming :: Setsockopt : Socket Operation On Non-socket Getting Error?

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

Programming :: Socket Programming: Insertion Of 0x00 Into The Stream?

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

Programming :: Build Ip Packet With C,socket Programming?

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

Programming :: Raw Socket Programming ( Head Is Going To Explode )?

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

Programming :: Send File Through Raw Socket Using C Programming

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

Programming :: Socket Programming - Connect To An IRC Server In A C

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

Programming :: Socket Programming In Module Perl

Jul 21, 2010

Where is the perl module for programming with sockets?

View 4 Replies View Related

Programming :: Socket Programming Select Interface

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

Programming :: Socket Programming Send File

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

Programming :: Paralel Port Kernel Module Programming

Jan 5, 2011

do you have any code to flash led lights with paralel port (device driver programming)or any lecture about this subject .if there is a working code this would be better ofcourse.

View 1 Replies View Related

Programming :: Rs232 Serial Port Programming?

Jun 1, 2010

I have been working on writing a small rs232 driver like minicom for months. I am almost there, I have the interrupt service routine running, I can read() ok. However when I write(), it returns the number of characters written, 1, but nothing is actually written out the port. I researched termios, and they say that serial port programming is really messy in linux/unix.

I am probably not setting up the port parameters correctly, or my write() function is not doing what it is supposed to. As I said, write() is returning successful. Other comm programs run ok (picocom & gtkterm) on my hardware. I am running knoppix/debian on an ancient computer. I saw other guys using slackware.

View 14 Replies View Related

Programming :: Serial Port Programming String?

Nov 24, 2010

I have a serial port program which is reading a string .if(read(readfd,sResult,1)>0)where sResult is unsigned char sResult[10];if sResult is array of 10 then iam getting string perfectly but if iam making sResult only as unsigned char I am getting NULL value CODE BELOW

Code:
unsigned char sResult;
main()
{
readfd = open("/dev/ttyUSB0", O_RDONLY);
if (readfd == -1)
{
perror("READ: open_port: Unable to open /dev/ttyUSB0-

[Code]...

View 2 Replies View Related

Programming :: Send A UDP Msg Across A Socket?

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

Programming :: Name A Socket By Bind?

Oct 20, 2010

How does bind system call names a socket.Code:bind(server_sockfd, (struct sockaddr *)&server_address, server_len);I see use of bind in majority of programms as above.But any of the arguments is not the name of socket.

View 1 Replies View Related







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