Network Communication Question - sockets

I would like to ask a question about network communication.
The Question is:
A server uses the socket interface on the Lunix platform,
and a client uses Winock on the Windows platform.
Can they communicate?
Explain briefly.
I guess the answer is NO.
I guess it is due to the compatibility between 2 different socket interface?!
But I am not sure my estimation is right or not.
So, I hope someone could give me some comments about this questions.
Thank you very much!

Not right at all.
The APIs are different, but both sockets create packets written to a standard format described in RFC 793 and lots of subsequent revisions and additions.
Follow that packet format, and implementations written for different platforms and in different languages will talk to each other.
This is the magic of the internet.

Related

File Transfer Protocol using TCP

im a university student and I've been tasked with creating a simple File Transfer Protocol using TCP between two machines.
I have very basic knowledge about sockets, and I've been using Linux for a bit. Is it possible to create two virtual machines on VirtualBox (linux machines) and have one be the server and the other be the client? Is that the right way to go about it?
Another question I have is for protocol specification. Is this something I specify in the client or server program or in a separate program?
Other than that, I would appreciate any useful resources or examples you can provide me as a starting point, as it's taking me a lot longer than I thought to really understand how to accomplish this through resources I currrently have. I apologize to any of you who feel this is an unproductive post but I am simply seeking any advice I can get from you more experienced programmers out there.
Thanks!
Is it possible to create two virtual machines on VirtualBox (linux
machines) and have one be the server and the other be the client? Is
that the right way to go about it?
You can do that, but to start with you might find it simpler to run the client and server programs both on the same host. There is no requirement that they must run on separate machines (virtual or otherwise).
Another question I have is for protocol specification. Is this
something I specify in the client or server program or in a separate
program?
The protocol specification is part of the documentation; it's not part of either program. Both programs will have to follow the specification in order to interoperate with each other properly, of course.
Other than that, I would appreciate any useful resources or examples you can provide me as a starting point,
Pointers to resources/examples are off-topic for StackOverflow, but you can google e.g. "TCP programming tutorial" or "TCP programming FAQ" or similar and you should find lots of content.

(Recommendations): Libraries for packet crafting, capture and analysis [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I think I summed it up in the title. Regarding the question, I have been evaluating my options for utilities that allow me to craft, capture, and analyze TCP/IP packets. I am very new to network programming and I am still learning as I go, but at this point, I want to write a program that establishes a TCP connection.
Here are my goals (long term to short term):
Deploy and code a system that can establish an ssh connection between two computers behind NATS given their local host names (i.e. feynman.home to feynman.work) and the IP addresses of their routers. I would also like to be able to guide the connection across a set of hops if possible/necessary.
No using third parties or closed source code of any kind. #
Rewrite (and possibly modify) pwnat in a "cleaner" format (i.e. using some well developed library for a high level language.)
Establish ssh connection between two hosts behind the same NAT (using my own code of course.)
Establish TCP connection between two hosts behind the same NAT (using my own code of course.)
I have managed to find netexpect which seemed very promising until it failed to build on my Mac OS X (my computer is going through a glitchy period right now.) Netexpect may well be the best option, but I have come across quite a few others (e.g. scapy and its perl and ruby implementations.) Many of these are not well maintained (e.g. scapy and its perl and ruby implementations.)
So, I thought it would be best to bring the question to stackoverflow (unless there is a better stackexchange I am not aware of.)
*Given the current state of my computer (don't ask) portability is important.
*I would prefer something well maintained/under active developement as to best assure I will have all the tools I will need for my short and long term goals.
*Finally, I would prefer something that uses an interpreted language for a host of reasons ranging from my experience to my preference.
#Yes I am fully aware there are easier ways. I want to do it my way because this just as much a learning experience as it is practical.
I know you are looking for a library on an interpreted language, but libcrafter is very easy to use. Is a C++ library for crafting and parsing network packets. On the future, it will support more protocols.
Most of what you described involving routing the connection between multiple hops/NATs - isn't done in the SSH client at all. It would involve having access to several network routers and setting up all those NATs in advance, then those translations would already happen automatically when the connection is routed through.
Are you talking about proxying your connections through multiple servers? That could be accomplished by a macro that logs in to server A, then automatically invokes ssh again from server A to get to server B and so on.
Could you describe in some more detail what you are trying to accomplish?
Edit: I just read the description of pwnat. That is incredibly proprietary (and won't work in every situation anyway, since many configurations block ICMP completely). If you really wanted to try it out, you'll probably be stuck with C/C++. I don't think Java or .NET gives you the kind of low-level flexibility that you would need to packet craft, for security reasons. Have you looked at Ostinato: http://code.google.com/p/ostinato/wiki/Downloads?tm=2 or Nemesis: http://nemesis.sourceforge.net/
Pretty much everything on windows will use winpcap and on *nix it will use libpcap.
While I haven't tried it, this might work: http://www.codeproject.com/Articles/12458/SharpPcap-A-Packet-Capture-Framework-for-NET
It says it SharpPcap handles interfacing with winpcap... so depending on what they implemented, or whether you can extend that functionality, you may be able to put something together.
Or, in java, you might be able to use something like this as a starting point: http://jpcap.sourceforge.net/
libtins is an open source, multi-platform, C++ library I've been developing for the past year. You can forge, sniff and interpret packets from network interfaces using it. It's very simple to use, and it provides a high level interface so you don't have to worry about endianness, internal protocol implementations, etc.
You can have a look at it at the library's website.

SoftPhone and linux

We are thinking about writing a softphone app. It would basically be a component of a system that has calls queued up from a database. It would interface with a LINUX server which has Asterisk installed.
My first question is
Whether we should write the softphone at all or just buy one?
Secondly, if we do,
what base libraries should be use?
I see SIP Sorcery on CodePlex. More than anything, I am looking for a sense of direction here. Any comments or recommendations would be appreciated.
The answer would depend on the capabilities you have in your team and the place you see your core value and the essence of the service you provide.
In most cases, I'd guess that you don't really care about SIP or doing anything fancy with it that require access to its low level. In such a case, I'd recommend getting a ready-made softphone - either a commercial one or an open source one. I'd go for a commercial one, as it will give you the peace of mind as to its stability and assistance with bug fixing and stuff.
To directly answer your question, one of the many open source softphones are likely to fit your needs, and allow slight modifications as needed. Under most open source licenses there is no obligation to distribute your code as long as you only use it internally (do not distribute the binary.)
Trying to guess what you are trying to do, it sounds like a call center like scenario, so one of the many call queue implementations out there might fit your needs.
I had to write an own softphone and I found a great guide how to achieve it. In the guide there are 10 steps provided for having an own softphone (voip-sip-sdk.com on page 272)
I found it useful and maybe you will find it as well.

SIP server programming

I'm new to SIP/VoIP programming. I want to implement a SIP server mainly for registering and proxing. I know to start from scratch is foolishness, but then what options do I have? I have been doing google-ing for a couple of days, and I got some few options to work with-
SIP JAIN
SIPServlet
Please comment on these items and some related materials. It would be helpful if someone can comment on the programming languages that suits SIP best, for all I'm more inclined towards Java.
Regards,
There are already some Open Source SIP proxy / registrars available: OpenSIPS and Kamailio. Both are written in C.
Do you have any specific need for writing a SIP proxy from scratch? Maybe you could extend one of the available ones to suit your needs?

Most effective way to do networking on Mac/iPhone?

What would be the most effective way (that is, best ratio of effort vs readability and maintainability) to establish TCP connection or send UDP datagrams on Mac and iPhone? I'm very familiar with classic BSD sockets, but I'm not aiming for portability right now; I'm just trying to be quickly done with a small project.
I'd love to have an Apple-provided Objective-C wrapper, but I'd like to hear some thoughts on what people are commonly doing. If you think BSD sockets are the way to go, feel free to punch in some thoughts, too: I'm really just interested in finding the "right way" to do it.
Let's presume the protocol to be a custom one, so our needs cannot be serviced by the Cocoa-based HTTP client classes :)
My current aim is to stream device status (e.g. accelerometer) over the network over UDP while also maintaining signaling and delivery-guaranteed-event (e.g. button pressed) connection over TCP. A desktop application would display this status.
However, my current application is just what made me ask the question; I'm wondering what people generally do. When I last seriously worked with VB6 about 7-8 years ago, WinSock ActiveX control did things a bit different than what is done with BSD sockets, no matter what it did under the hood.
For networking, the simple answer is,
(1) ASIHttpRequest ........ NOTE - this QA is very old. Unfortunately ASIHttpRequest is of historic interest only and is no longer available.
(2) AsyncSocket
(3) When you're starting out ... GameKit (a child can use it)
(4) Just use Bonjour (two lines of code) to find other devices.
"an Apple-provided Objective-C wrapper" ... AsyncSockets (written originally by the mysterious Dustin J. Voss) is SO GOOD that Apple just won't bother trying to write one!
AsyncSockets is exactly what you're after. It is used everywhere in the 300,000 iFone apps. It "is" networking on the iFone. Hope it helps.
AGAIN NOTE - this QA is very old. You can easily now find "modern versions of" software like AsyncSockets.
BTW, it's worth nothing that there is absolutely nothing wrong - at all - with just using GK .. the performance can be spectacular. About the only downside is that pairing simply takes a plain long time with GK. And it's a childish mess created for ten year olds learning programming. You will be able to do 100x faster pairing working directly with AsyncSockets.
You may prefer to use some toy GK code, while you figure out Bonjour and all that.
I would suggest the consensus of opinion is that there is no point working at an even lower level (ie, raw sockets) than AsyncSocket .. there's not much more performance to be had in there.
NOTE - if you are new to gamekit / iOS be sure to read this critical tip!
Client/Server GKSessions
hope it helps.
Your question can't really be answered with any detail because you haven't described what you want to do. The best answer I can give is to read the introductory networking guides for Mac and iOS.
Update
I don't think there's any "easy Cocoa way" built in for UDP. I recall this discussion has come up several times on the cocoa-dev list. The cocoaasyncsocket project has been mentioned various places. It claims:
AsyncUdpSocket is a UDP/IP socket
networking library that wraps
CFSocket. It works almost exactly like
the TCP version, but is designed
specifically for UDP. This includes
queued non-blocking send/receive
operations, full delegate support,
run-loop based, self-contained class,
and support for IPv4 and IPv6.