Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An easy to use Objective-C draft 10 websocket implementation. NOTE I don't use this anymore, someone should become the new main fork.

branch: master


A websocket server implementation, (you cannot instantiate an instance that does not bind to a port).

NOTE! I have not tested it extensively and there are many old WS versions. So you may well have to hack it to make it work. But! There is not much code. And! I believe it is quite readable. I will help! Mail me!

Tested against recent Chrome, Safari and Firefox versions. Only tested on Mac.

If you want a client implementation, use Square’s SocketRocket.


  • There's no support for fragmented frames.


  • ARC or Garbage Collection
  • Xcode 4.5

Example Usage

- (void)applicationDidFinishLaunching:(NSNotification *)note { = [[MBWebSocketServer alloc] initWithPort:13581 delegate:self];

- (void)webSocketServer:(MBWebSocketServer *)webSocketServer didAcceptConnection:(GCDAsyncSocket *)connection {
    NSLog(@"Connected to a client, we accept multiple connections");

- (void)webSocketServer:(MBWebSocketServer *)webSocket didReceiveData:(NSData *)data fromConnection:(GCDAsyncSocket *) {
    NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);

    [connection writeWebSocketFrame:@"Thanks for the data!"]; // you can write NSStrings or NSDatas

- (void)webSocketServer:(MBWebSocketServer *)webSocketServer clientDisconnected:(GCDAsyncSocket *)connection {
    NSLog(@"Disconnected from client: %@", connection);

- (void)webSocketServer:(MBWebSocketServer *)webSocketServer couldNotParseRawData:(NSData *)rawData fromConnection:(GCDAsyncSocket *)connection error:(NSError *)error {
    NSLog(@"MBWebSocketServer error: %@", error);


I’m Max Howell and I'm a splendid chap

Something went wrong with that request. Please try again.