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


ADVERTISEMENT

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

Networking :: MULTICAST Address And Port - Socket Listen Only On Port?

Feb 12, 2009

I make an application on GNU/Linux which listening on a MULTICAST stream, so I open my unconnected socket, bind it on a MULTICAST address and a port, join the multicast group with the "setsockopt (IP_ADD_MEMBERSHIP)", then I receive datagram on my socket.

Now I've two different instances of the same application that run with their own MULTICAST address and port. And what I found strange is that, after a misconfiguration, I switch the ports, for example:

Emitting on 225.0.0.1/23451 and 225.0.0.2/23452
Receiving on 225.0.0.1/23452 and 225.0.0.2/23451

And my receiving part doesn't care about the MULTICAST address, it looks like the socket is listening on the port number only! I mean that the receiver [225.0.0.1/23452] take its datagrams from emitter [225.0.0.2/23452] and vice-versa!

View 2 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

Ubuntu :: Port Forwarding Crutch - Number Of Apps That Are Unable To Have The Outgoing Port Changed ?

Mar 28, 2010

I'm not that great with mailservers, and just been thrown a curveball with a MS Exchange environment for which there is apparently no solution... yeah, right. But is there a workaround?

The problem is that the site mail (SMTP) needs to be sent via port 26 instead of the commonly used 25. Port 25 is mapped to a mailfilter, which apparently causes havoc with some of the mail, and the techs that have been on site trying to coax the Exchange server to co-operate have said that the only way would be to get rid of the filter.

The problem is that there are number of apps that are unable to have the outgoing port changed and so keep sending mail out on port 25.

I look after the Unix/Linux side of things at work, and I was wondering if there was an easy way to set up a Ubuntu box to receive mail on port 25 and just forward it to the MS box on port 26? So, in other words (and I hope this makes sense): monitor port 25, and forward whatever comes in on port 25 to the server on port 26. Simple portforwarding, or is it? What steps do I need to take?

View 2 Replies View Related

Software :: What Is Maximum Number Of Bytes Is Possible To Send From Udp Socket?

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

Networking :: TCP And UDP Socket On Same Port ?

Nov 20, 2009

Can we open TCP and UDP socket on same port number?

View 1 Replies View Related

Networking :: Raw SCTP Socket Cannot Bind With Port?

Jul 26, 2010

If I open a raw SCTP socket, am I able to bind to a specific port? (I only want to see SCTP packets from a particular IP address AND port.) Or, any raw SCTP socket, regardless of port binding , will get all SCTP packets received by the OS from that IP address? The port doesn't matter and is ignored.

View 1 Replies View Related

Networking :: How To Open A Port - Failed To Open The TCP Port Number In The License

Jun 20, 2009

I am running lmgrd on CentOS5, but it returns Failed to open the TCP port number in the license. The port is 27000, how can I open that port?

View 5 Replies View Related

Ubuntu :: Failed To Create UDP Socket (SIP) On Port 5060 Address

Mar 13, 2010

I can't seem to get on my Twinkle SIP Phone, it says: "Failed to create a UDP Socket (SIP) on port 5060 Address already in use" after that message it brings me back to the window were I'm supposed to run my profile, how do I fix this?

View 6 Replies View Related

Debian Configuration :: Cannot Open Java Socket - Port (9955) Closed

Feb 26, 2010

I have a java application that I wrote recently. It runs off port 9955. The application runs great on my mac server. When I installed it on my linux box i cant get to it from outside the box. A port scan shows the port as closed. I flushed my iptables, did not help. I can telnet into the app locally, from the server and it works great. I cannot telnet from outside the server. I have a reference to the application in /etc/services as a tcp port (which it is).

netstat shows it as listening
netstat --listen
tcp6 0 0 [::]: SimpleSocketTest [::]:* LISTEN
netstat -anp | grep 9955
tcp6 0 0 ::: 9955 :::* LISTEN 1484/java

View 4 Replies View Related

Networking :: Fedora 11 Gnome Application Can't Connect To Socket Port 8005

Jul 3, 2009

I have an x application I am trying to run under gnome. It assumes a fixed ip address and exclusive use of the eth0. I have run it under gnome on RHEL 5.3. I set the ip address and ifconfig confirms the correct address. When I run it I get "SocketConnect() error:

Resource temporarily unavailabele, port 8005. (on the terminal that I started it)

This is indicative that it has failed to make a connection to the outside world. One difference I notice between the non-working and the working is that, the error message seems to stop coming out on the fedora gnome, almost immediately, whereas on the other installations it will come out indefinitely until it connects. is virb0 interferring. What is different in the networking on fedora 11 then RHEL?

View 2 Replies View Related

Networking :: Using A Perl Script To Test For A Socket Listening On A UDP Port On A Remote Host?

Mar 10, 2011

is it possible using a perl script to test for a socket listening on a UDP port on a remote host ?I work in an environment where netcat is not allowed and from time to time I need to see if a UDP port is open on a remote host.

View 6 Replies View Related

General :: Changing The SSH Port Number?

Jan 12, 2011

im using CentOS 5.2 and cant change my default ssh port number. I have edited /etc/ssh/sshd_config to this

Code:

#$OpenBSD: ssh_config,v 1.21 2005/12/06 22:38:27 reyk Exp $
# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files

[code]....

I have then restarted ssh by typing (as root) "sbin/service sshd restart" and it restarts fine but still is on 22 and not 222.

View 9 Replies View Related

Red Hat / Fedora :: Changing The Port Number To Something Like 81?

Jan 16, 2011

i have installed CentOS along with ISPConfig. For some reason apache will not run it says there are no listening sockets avaliable. I have done a netstat and also tried nmap to see if any other service was using port 80 but it doesnt show anything. I also tried changing the port number to something like 81 still no go. On bootup of CentOS it shows the error and a message saying unable to open logs.

View 1 Replies View Related

Server :: Get FTP To Use A Specific Port Number?

Mar 17, 2011

How do I get FTP to use a specific port number? .. I read the manual but cannot work this one out.

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







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