Using Winsock and C to talk with an FTP server - winsock

How would I go about doing this?

TCP/IP Sockets in C: Practical Guide for Programmers has a number of C code examples using Winsock.
There isn't one for FTP but it will get you on your way.

Although you can use Winsock you'll be better off if you use a higher level API, such as WinINet, which already implements the FTP protocol.

Read the FTP RFC.

Related

Sockets used to send messages between machines

I want to make a sort of chat server between my desktop and my laptop using sockets. Does anybody know of a good tutorial on this or if you have any files with comments on it that I can use as reference?
This could be good at the beginning of your adventure:
https://medium.com/swlh/lets-write-a-chat-app-in-python-f6783a9ac170

Push notifications with sockets for desktop WPF aplication (No Win8 App)

I'm trying to get into an implementation of some kind of push notification for a Windows WPF client application and a java backed server.
The idea is to avoid as much as possible polling the server, so I thought to implement it with sockets and messages, and relying in some easy pulling solution in case a socket connection could not be done, (Firewalls, etc).
In the other hand is important that the data traveling get encrypted.
So I have a couple of question/"request for opinions" more related with the WPF client:
Perhaps already exist some solution for that, any tips?
Could be good to think in some SSL sockets connections for that?
If 2 is OK, there is some native solution for secure sockets in .net or any library?
If sockets solutions is an option, I guess i need to go through port 443 and by the way it will avoid many problems with firewalls and so on, am i right?
I know there is many question but all are related to the same problem.
Thanks in advance.
http://clientengine.codeplex.com/
Yes, SSL is good if you need to keep the data secure during transfer
Yes, http://clientengine.codeplex.com/ indicates it supports SSL/TLS
Well, it depends on whether you are controlling the server or not. If you have control over it you can use whatever port you want.

Listening to a tcp port in iphone

I need to listen to a TCP port and collect the binary data from the port in my iphone how this could be done . I had searched a lot for the same but did not find anything worth, please help me any links, or sample code be greatly appretiated
The only thing you need to do is open a socket, you have two options:
Create the socket in pure C:
Sockets in C
Or use the classes that Apple provides to work with sockets:
Introduction to Stream Programming Guide for Cocoa
If you are going to do something simple, the first option is the easiest
There is a very useful socket library called GCDAsyncSocket on github that can be used to make both TCP/UDP sockets and comes with delegate methods for reading and writing data
GCDAsyncSocket

Difference between socket and websocket?

I'm building web app that needs to communicate with another application using socket connections. This is new territory for me, so want to be sure that sockets are different than websockets. It seems like they're only conceptually similar.
Asking because initially I'd planned on using Django as the foundation for my project, but in the SO post I linked to above it's made very clear that websockets aren't possible (or at least not reliable, even with something like django-websockets) using the preferred Django setup (Apache with mod_wsgi). Yet I've found other posts that casually import Python's socket module for something as simple as grabbing the server's hostname.
So:
Are they really different?
Is there any reason not to use Django for a project that relies on establishing socket connections with an outside server?
To answer your questions.
Even though they achieve (in general) similar things, yes, they are really different. WebSockets typically run from browsers connecting to Application Server over a protocol similar to HTTP that runs over TCP/IP. So they are primarily for Web Applications that require a permanent connection to its server. On the other hand, plain sockets are more powerful and generic. They run over TCP/IP but they are not restricted to browsers or HTTP protocol. They could be used to implement any kind of communication.
No. There is no reason.
Websockets use sockets in their implementation. Websockets are based on a standard protocol (now in final call, but not yet final) that defines a connection "handshake" and message "frame." The two sides go through the handshake procedure to mutually accept a connection and then use the standard message format ("frame") to pass messages back and forth.
I'm developing a framework that will allow you to communicate directly machine to machine with installed software. It might suit your purpose. You can follow my blog if you wish: http://highlevellogic.blogspot.com/2011/09/websocket-server-demonstration_26.html
WebSocket is just another application level protocol over TCP protocol, just like HTTP.
Some snippets < Spring in Action 4> quoted below, hope it can help you understand WebSocket better.
In its simplest form, a WebSocket is just a communication channel
between two applications (not necessarily a browser is
involved)...WebSocket communication can be used between any kinds of
applications, but the most common use of WebSocket is to facilitate
communication between a server application and a browser-based application.
You'd have to use WebSockets (or some similar protocol module e.g. as supported by the Flash plugin) because a normal browser application simply can't open a pure TCP socket.
The Socket.IO module available for node.js can help a lot, but note that it is not a pure WebSocket module in its own right.
It's actually a more generic communications module that can run on top of various other network protocols, including WebSockets, and Flash sockets.
Hence if you want to use Socket.IO on the server end you must also use their client code and objects. You can't easily make raw WebSocket connections to a socket.io server as you'd have to emulate their message protocol.
WebSocket is a computer communications transport protocol (like TCP, HTTP 1.0, HTTP 1.1, HTTP 2.0, QUIC, WebRTC, etc.)
Socket is an endpoint for sending and receiving data across the network (like Port number)
Example of Socket:
(TCP, 8.8.8.4, 8080, 8.8.8.8, 8070)
where:
(protocol, local address, local port, remote address, remote port)
Regarding your question (b), be aware that the Websocket specification hasn't been finalised. According to the W3C:
Implementors should be aware that this specification is not stable.
Personally I regard Websockets to be waaay too bleeding edge to use at present. Though I'll probably find them useful in a year or so.

Objective-c TCP/IP client

I have a TCP server running on a machine. (implemented in Java). I need to connect to that server from a iPhone and send data to the server and also, receive data on the iphone when server pushes me data. So I need to be notified when data pushes from the server.
Is there a way to do this in Objective C(socket programming). Although I googled I couldn't find a solution. But I saw CFSocket etc.
Please anyone have a solution?
after a possible solutions in the internet, I found a nice asynchronous TCP and UDP socket Library here. (http://code.google.com/p/cocoaasyncsocket). This library worked really well for me so far. This wraps the CFSocket and CFStream.
Thanks for your replies.
You can use the CFNetwork family of classes to implement lower level sockets. Apple has an introduction document that describes the use of these classes.
CFSocket calls and similar will let you create sockets. You can then use CFStreamCreatePairWithSocket() to create a CFReadStreamRef and CFWriteStreamRef, which you can cast to NSInputStream* and NSOutputStream*.