[Plugin] SAMP WinSock Plugin - Beta
#1

WinSock Plugin - Beta 1.2
This plugin is a functioning, windows-only socket plugin I designed as per a friend's request. This plugin uses assigned IDs to manage multiple connections simultaneously, it uses threading for reading and listening and the main thread for sending data and connecting.
This plugin supports only one connection per socket at any given time, once a connection is accepted by a listening socket it will turn into an active socket, an active socket must be disconnected before it can connect or listen for another connection.

Big credit to StrickenKid for releasing the source to some of his work, an effective tutorial in its own rights.

This version only works under Windows operating systems with support for WinSock 2.2. Modifying it to be cross-platform compatible is currently being considered.
Functions
pawn Код:
native socket_create( id );
// Used to create a socket to be used by the plugin, only one socket with this ID can be used at any given time.

native socket_destroy( id );
// Used to destroy a socket, this will first call the disconnect function and then the ID will be available for use again.

native socket_connect( id, ip[], port);
// Used to make the inactive socket connect to a remote IP address's port.

native socket_disconnect( id );
// Used to make an active socket close.

native socket_send( id, data[] );
// Used to send data over an active socket.

native socket_listen( id, port );
// Used to make the socket listen for an incoming connection on the specified port.

native socket_stoplisten( id );
// Used to make the socket stop listening.

native socket_id_available( id );
// Returns true if the ID is not in use, false otherwise.

native socket_isactive( id );
// Returns true if the ID is in use, false if otherwise or not found

native socket_islistening( id );
// Returns true if the ID is listening, false if otherwise or not found

native socket_getbuffersize( id );
// Returns the size of the socket's buffer

native socket_setbuffersize( id, size );
// Returns true if the buffer size has been set, false otherwise or not found

native socket_cleanstring( source[], dest[] );
// Creates a copy of the source string with all non-printable characters stripped.
Callbacks
pawn Код:
forward onSocketConnect( id, ip[], port );
// Called when a socket connects to a remote host, or when a listening socket accepts a connection and becomes an active socket. The IP and port belong to the remote host.

forward onSocketDisconnect( id );
// Called when a socket disconnects, either on the host or server's end.

forward onSocketReceive( id, data[] );
// Called when a socket receives data from the remote host.


Changelog
Version 1.2
  • + added the ability to specify the buffer size per socket
  • + added socket_getbuffersize( id )
  • + added socket_setbuffersize( id, size )
  • + added a function to return a string stripped of non-printable characters
  • + added socket_cleanstring( source[], dest[] )
  • - removed automatic filtration of non-printable characters
  • - removed a debug message that got left in version 1.1
Version 1.1
  • + added ProcessTick support
  • + added socket_isactive( id )
  • + added socket_islistening( id )
  • + added some comments to the SampSocket class, planning more
  • + added credit where credit is due
  • = moved the core code around a lot


Current Version
SampWinSock 1.2

Older Versions
SampWinSock 1.1
SampWinSock 1.0
Reply
#2

This is AWESOME, excellent job, completely intelligent.
Can you release the source of the plugin?
Reply
#3

Quote:
Originally Posted by Deskoft
Посмотреть сообщение
This is AWESOME, excellent job, completely intelligent.
Can you release the source of the plugin?
The source project is contained within the archive, it was created with Visual Studio 2010, so that would be the easiest solution to opening it.
Reply
#4

Thanks for this release, I plan making a remote rcon with custom commands with this.
Reply
#5

Quote:
Originally Posted by Deskoft
Посмотреть сообщение
Thanks for this release, I plan making a remote rcon with custom commands with this.
No problem

The whole reason I made this was so me and said friend could design a network protocol and create scripts in other languages, the server would run a bare script that executes functions based on the packets received through the connection to a server made in another language.
Reply
#6

Quote:
Originally Posted by langricr
Посмотреть сообщение
No problem

The whole reason I made this was so me and said friend could design a network protocol and create scripts in other languages, the server would run a bare script that executes functions based on the packets received through the connection to a server made in another language.
This can be widely used, although it's not that safe, it can be compared to the TCP/IP system in batch, basic, but very useful.
Reply
#7

This is AWESOME, excellent job, completely intelligent.І
Reply
#8

I can see you've stolen code, and the basic architecture from my sockets plugin.
Reply
#9

Quote:
Originally Posted by StrickenKid
Посмотреть сообщение
I can see you've stolen code, and the basic architecture from my sockets plugin.
Yes, I did use part of your code as a reference having rarely programmed in C++ before, but when my friend mentioned that your plugin failed to operate and that you weren't willing to repair it ( on top of it only supporting one socket), I opted to create a replacement. The only code I explicitly copied was the GetString method and the basic callback loop when locating amx methods. Other than that, please point out how I've stolen your "basic architecture".
Reply
#10

I'm not going to waste my time over this, but if you put both the projects side by side and compare.... It looks like you've just changed a few things around, changed the order of some functions, and added the functionality of multiple connections.... I've also noticed some problems with yours which will drastically affect the operation of it.

But all that aside, you should have at least given me credit, or even asked for permission... You have just copied code from my work.

Also,

Код:
/**
 *     SA:MP WinSock
 *  © Copyright 2010, <__Ethan__>
 *
 **/

#if defined _winsock_inc
	#endinput
#endif

#define _winsock_inc
#pragma library winsock

// plugin natives

native socket_create( id );
native socket_destroy( id );
native socket_id_available( id );

native socket_connect( id, ip[], port);
native socket_disconnect( id );

native socket_listen( id, port );
native socket_stoplisten( id );
native socket_send( id, data[] );

// plugin callbacks
forward onSocketConnect( id, ip[], port );
forward onSocketDisconnect( id );
forward onSocketReceive( id, data[] );
Your include has my copyright?
Reply
#11

Quote:
Originally Posted by StrickenKid
Посмотреть сообщение
I'm not going to waste my time over this, but if you put both the projects side by side and compare.... It looks like you've just changed a few things around, changed the order of some functions, and added the functionality of multiple connections.... I've also noticed some problems with yours which will drastically affect the operation of it.

But all that aside, you should have at least given me credit, or even asked for permission... You have just copied code from my work.

Also,

Код:
truncated lengthy code
Your include has my copyright?
Ah yes, you got me there, the include was just edited. I'll change the include file and give you credit where you deserve it. If you are that stubborn about my good will and calling it a copy, go ahead and do so, but I'm not releasing something half-finished and broken.
Reply
#12

You're calling me stubborn because I want credit when its rightfully mine, yet you're calling my work "half-finished and broken".

Why would you copy my plugin if its "half-finished and broken", why wouldn't you start from scratch?

I can also tell you have no idea what you're doing with sa-mp plugins because of many mistakes you have made in your plugin will cause it not to work properly.
Reply
#13

Instead of just telling him of the plugins problems, you took over the project and re-released it as your own. It is his project and he will get to it when he can. As he said, you should have started from scratch.
Reply
#14

I did start the project from scratch, as stated before the only thing I explicitly copied from the source was the GetString method (which I've now replaced), and the loop. Other than that, I typed out every character in it by hand. The only reason the include has his copyright is because I opened it in notepad++ and saved it under a new name, since I didn't know how to make it in VS. Everything else I wrote after scowering the internet.

See for yourselves:
From here to
/imageshack/img694/9315/history1z.png
/imageshack/img193/4938/history2d.png
/imageshack/img864/7100/history3.png
/imageshack/img695/8684/history4e.png
/imageshack/img30/3888/history5.png


Edit: Now that I've had some time to sober up, I've made some strong modifications to the plugin, see the changelog for details.
Reply
#15

Pathetic
Reply
#16

Quote:
Originally Posted by nemesis-
Посмотреть сообщение
Pathetic
As is your reply, what is pathetic pray tell?
Reply
#17

Nice plugin! I love it! Will def. use it
Reply
#18

Quote:
Originally Posted by langricr
Посмотреть сообщение
As is your reply, what is pathetic pray tell?
1) Plugin coder posts plugin.
2) Plugin coder is caught stealing code.
3) Plugin coder understates code theft and tries reasoning why the theft was acceptable.
4) Plugin coder caught by accuser using accuser's very own copyright.
5) Plugin coder insults accuser when accuser is rightfully upset over proven code theft.
6) Plugin coder back-peddles even further by stating he's changed tidbits of code to try and make-up for being a code thief.

That is what was pathetic. Right after #2 you should have admitted it, apologized, inserted credits to StrickenKid, and moved on. Instead, you destroyed any credibility you might have had, showed your lack of tact and class and ruined a perfectly good opportunity to show that you had any to begin with. Bravo. Hopefully you learned from this mistake and are not discouraged by any of my harsh remarks - I commend you on taking the time to make a contribution to this community which is more than most people do.
Reply
#19

lol this guy got told. Atleast leave him in the credits and don't say it's all of your work.
Reply
#20

Quote:
Originally Posted by nemesis-
Посмотреть сообщение
1) Plugin coder posts plugin.
2) Plugin coder is caught stealing code.
3) Plugin coder understates code theft and tries reasoning why the theft was acceptable.
4) Plugin coder caught by accuser using accuser's very own copyright.
5) Plugin coder insults accuser when accuser is rightfully upset over proven code theft.
6) Plugin coder back-peddles even further by stating he's changed tidbits of code to try and make-up for being a code thief.

That is what was pathetic. Right after #2 you should have admitted it, apologized, inserted credits to StrickenKid, and moved on. Instead, you destroyed any credibility you might have had, showed your lack of tact and class and ruined a perfectly good opportunity to show that you had any to begin with. Bravo. Hopefully you learned from this mistake and are not discouraged by any of my harsh remarks - I commend you on taking the time to make a contribution to this community which is more than most people do.
You aren't making much sense, its kind of hard to steal code thats been marked with the general public license, I don't have to give him credits if I don't want to, I'm free to modify it and use it as I see fit. I gave him his credits as he requested. From his accusations, it was apparent that it looked like I just opened up his project files, willy-nillied some bits together to make it work and released it again, which is not the case, I defended myself accordingly. But hey, I'm not here to waste time, if you don't like it then don't use it.

Quote:
Originally Posted by dr.pepper
Посмотреть сообщение
lol this guy got told. Atleast leave him in the credits and don't say it's all of your work.
Pray tell when I ever mentioned it was all of my work?

Код:
/*
	SA:MP Sockets Plugin BETA R2
	Copyright © 2010, StrickenKid

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
http://www.gnu.org/licenses/gpl.html
Код:
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses 
are designed to make sure that you have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you want it, that you can change the
software or use pieces of it in new free programs, and that you know you can do these things.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)