Is it possible to set the port number in the URL for Kiwi IRC already?
This is what I tried: https://kiwiirc.com/client/irc.spacetrace.org/spacetrace?port=6666&nick=kiwichatter
The server and nick works like this but not the port.
I couldn't find a hint in the documentation
You can set the port with the hostname in the standard way: irc.spacetrace.org:6666
Tip: Add a ? to the nick to generate a random number to stop people getting 'nickname in use' errors.
https://kiwiirc.com/client/irc.spacetrace.org:6666/spacetrace/?nick=kiwichatter?
Just type your port next to your nickname you selected. That ought to work.
Related
I'm trying to access a buttonbox to record subject responses in matlab, but I can't access the usb port or the device attached. I've tried a lot of variations of the following code. what I currently have is:
port = serial ('COM2', 'BaudRate', 19200);
handle = CMUBox('Open', 'pst', port);
I keep getting all error messages either that I'm using the wrong argument type (referring to the 3rd arg 'port' in the second line) or that no such serial port device exists (again referring to 'port').
Any ideas?
The input to CMUbox should be the port name, like 'COM2', not a port object, like the variable port. See the
CMUBox docs for more details.
PS - Make sure that "COM2" is a correct port number. Often (not always) with Windows only COM3 and higher will be valid external devices.
I am creating a server socket as
% set serverSocket [socket -server accept 0]
sock005DBCC0
Since I am using the port number as zero, the operating system will allocate a free port to the server socket.
From the man page, I understand that we have to use -sockname with chan configure to get the port number.
-sockname
For client sockets (including the channels that get created when a
client connects to a server socket) this option returns a list of
three elements, the address, the host name and the port number for the
socket. If the host name cannot be computed, the second element is
identical to the address, the first element of the list.
% chan configure $serverSocket -sockname
0.0.0.0 0.0.0.0 65495 :: :: 65495
As you can see the above command returns six elements. What is the significance of :: here ? Is it referring global scope ?
My actual intention is to get the port number to which the socket is listening.
So, in order to get the port number, can I retrieve the last element of the list alone as shown below?
% set serverPort [lindex [chan configure $serverSocket -sockname] end]
65495
%
The reason why I'm asking this is because of the repetition of that port number in that list.
There are two sets of three elements in that list precisely because the server socket under the covers is actually two: one for IPv4 and one for IPv6. Tcl opens both since it doesn't know how clients are going to connect ahead of time (unless you use the -myaddr option when making the server option to make it so that only one protocol is possible). They could theoretically be on different ports, but that's really quite unlikely as Tcl tries to use the same port for both; your idea about taking the last item is probably fine.
If you really care, when you've got two addresses the first one will be the IPv4 address and the second will be the IPv6 address, so you can use lindex … 2 or lindex … 5 (or lindex … end) to pick exactly what you mean.
I'd probably do:
lassign [chan configure $serverSocket -sockname] serverAddress serverName serverPort
:: is the equivalent of 0.0.0.0, the unspecified address, for IPv6
(http://www.ietf.org/rfc/rfc3513.txt, page)
It looks like the port is 65495. You're getting two sets of three elements, one for ipv4, one for ipv6
If I open up a port on our server to listen out for incoming messages (ie - strings of text), how can i send those messages? are their any example codes out there that are useful?
I have downloaded a few sample projects but none seem to do i want.
what code is used to specify the ip address and port number?
Here you wil find exactly what you need.
It is a wrapper class called AsyncSocket; to connect you just send it the string with the ip and an int with the port.
It will do all the work on ints own.
To send info you just turn your string into NSData if I remember correctly.
It has a very easy to follow sample so you should be up and running in about 20 min.
Look up any tutorial text on networking.
For instance, there are a bunch of echo server implmentations at rosettacode.
i need to get the ip address from the given host name. For example,if "google.com" is given i need the ip address of google.com. How to achive this in iphone?
For iPhone, use CFHost.
See the POSIX function getaddrinfo().
Do it like any other POSIX systems, i.e. use getaddrinfo() (See http://en.wikipedia.org/wiki/Getaddrinfo).
I am writing a UDP test client/server and i want to get it through firewall. Supposedly all i need to do is have both sides send to the correct IP and server. Getting an IP is not a problem but how do i have the client pick a random free port and report it to the user? I eventually would want it to connect to a matchmaker server but right now i need a simple working prototype and i would like to cout the port number so my friend/tester can send me the # via IM so we can test.
How do i get the port number?
sorry for the long desc. I notice people tell me not to do what i am asking when i dont give a desc :(
To use the highly technical term, this is actually a pretty icky problem or even a pair of icky problems. Depending on the configuration of the firewall, it will usually allow responses from another endpoint on the IP endpoint as the request came from. So... if you friend receives the UDP datagram using something like the recvfrom() system call, the address parameter will receive the IP endpoint information to respond to. So the other end should be able to respond with a sendto() using the same addressing information. Something like:
/* initiator */
struct sockaddr_in hisaddr;
memset(&hisaddr, 0, sizeof(hisaddr));
hisaddr.sin_addr.s_addr = htonl(target_ip);
hisaddr.sin_port = htons(target_port);
sendto(sd, msg_ptr, msg_sz, 0, (struct sockaddr*)&hisaddr, sizeof(hisaddr));
/* receiver */
struct sockaddr_in peeraddr;
socklen_t peer_sz = sizeof(peeraddr);
recvfrom(sd, buf_ptr, buf_sz, 0, (struct sockaddr*)&peeraddr, &peer_sz);
/* build response */
sendto(sd, msg_ptr, msg_sz, 0, (struct sockaddr*)&peeraddr, peer_sz);
The peeraddr on the other side will be your external address or, more correctly, the IP address of your firewall and the port number that it chose to use. The port number that you specify in your code may be completely different than the port that your friend would have to send data to. Ultimately, it might not matter what port you choose to use since the firewall might be sending and receiving on an entirely different port - this is what Network Address Translation is all about. I would recommend reading RFC3235 for some tips on how to overcome that hurdle.
The best approach IMHO is to:
Let the OS choose a port by either calling bind() with a zero port number or skipping the bind altogether
Having the client receive the address information from the socket layer (e.g., the fifth and sixth arguments to recvfrom())
The client sends response to the endpoint retrieved in the previous step
Tweak the firewall configurations until the previous steps work
Of course, all of the magic is in the last step. If you can disable NAT or ensure that the firewall is never going to switch ports, then nailing down a port number and bind-ing to it will work as well. You might want to take a look at %WINDIR%\system32\drivers\etc\services (or /etc/services depending on your OS inclination) to get an idea of what port numbers are reserved or generally in use.
bind() the socket before you send your data. Specify port 0 to bind(), and the OS will pick an unused port for you. You can then use getsockname() to find out what port wsa chosen.
Generally speaking - you - as the developer - choose the port. You can set your application to read the port from a config file or user input - but no magic firewall is going to tell you what port to use...
If I'm understanding your question correctly, I'm not sure there's a way to do what you want programatically (and even if there is, I don't think it's the right approach). I think you need to find a port that isn't in use on the server machine (and perhaps a different or the same port on the client machine, if communication is bi-directional) AND that port must be able to pass through your firewall. I assume since you say "getting an IP is not a problem", you've already configured your firewall to forward some or all ports to a specific computer inside the firewall? If so, the port you seek is one of the ones you forwarded. You can just pick an arbitrary one, as long as no other service is running on that port. Ports below 1024 are reserved, so you probably want to pick a higher number than that. You can use a simple portscanning tool such as nmap to see which services are running on your computer on which ports and pick a different one. Note that nmap can be fooled by firewalls and various bind rules when sockets are created.
I think you're better off picking a fixed port rather than relying on the random port number chosen by the O/S.
If you use a random port you'd have to change your firewall settings each and every time you run the program.
If you're using WINSOCK check this link:
http://msdn.microsoft.com/en-us/library/aa280717(VS.60).aspx
Basically you have 2 choices set the port to 0 and let the system assign you one or chose a random one try to open the socket if it doesn't work try another (be sure to steer clear of reserved ports)