-  [WT]  [PS]  [Home] [Manage]

[Return]
Posting mode: Reply
  1.   (reply to 5821)
  2. (for post and file deletion)
/pr/ - Programming
  • Supported file types are: GIF, JPG, PNG, WEBM
  • Maximum file size allowed is 10000 KB.
  • Images greater than 200x200 pixels will be thumbnailed.
  • Currently 451 unique user posts. View catalog

  • Blotter updated: 2018-08-24 Show/Hide Show All

Movies & TV 24/7 via Channel7: Web Player, .m3u file. Music via Radio7: Web Player, .m3u file.


Didn't get very far Basement Dwelling Neckbeard 26/01/31(Sat)00:39 No. 5821
5821

File 176981636253.jpg - (369.85KB , 1024x768 , Green Sea Turtle.jpg )

/* gcc -pthread telserve_*.c */ #include "telserv/globals.h" #include "telserv/connect.h" int main(int argc, char *argv[]){ int c; int read_size; server.sockID = socket(AF_INET, SOCK_STREAM, 0); if(server.sockID < 0){ perror("Socket Failure"); } else{ perror("Socket Creation"); } server.address.sin_family = AF_INET; server.address.sin_addr.s_addr = INADDR_ANY; server.address.sin_port = htons(PORT); if(bind(server.sockID, (struct sockaddr *) &server.address, sizeof(server.address)) < 0){ perror("Bind Failed"); } else{ perror("Bind Socket"); } for(client_cnt = 0; client_cnt < MAX_USERS; client_cnt++){ if(listen(server.sockID, 3) < 0){ perror("Failure to listen"); } else{ printf("Server listening on port %d\n", PORT); } c = sizeof(struct sockaddr_in); if(player[client_cnt].client.sockID = accept(server.sockID, (struct sockaddr *) &player[client_cnt].client.address, (socklen_t*)&c)){ puts("Connection Accepted"); pthread_create(&player[client_cnt].client.thread_id, NULL, connection_handler, (void*) &player[client_cnt].client.sockID); /*pthread_join(client[client_cnt].thread_id, NULL);*/ puts("Handler assigned"); } } return 0; }


Digging through some old projects and found this experiment I was working on. I think the idea was a p2p network from scratch. User data, messages, etc would be prepped into an xml file and shared accross contacts. By including mutual contexts in the requested xml the network could be self sustaining and eliminate the need for central company host or tracker. I have some handwritten notes here somewhere..
It's basically the concept behind distributed hash tables I think.


>>
Basement Dwelling Neckbeard 26/01/31(Sat)00:50 No. 5822

I wanted to write the UI in GTK, but the manual I had was one thousand pages of pdf- which is really just impossible to use as a reference. You can't flip between pages in an e-document.
So then I thought I'd use python, but it kinda got away from me and I ended up going to do other things.

import wx import os import xml.etree.ElementTree as ET def getXmlTree(var): tree = ET.parse(var) xmlroot = tree.getroot() return xmlroot, tree def fileBrowse(var): browse = wx.FileDialog(var, "Choose a file", "", "", "", wx.FD_OPEN) if browse.ShowModal() == wx.ID_OK: path = browse.GetPath() browse.Destroy() return path def MonitorInfoFunc(): if wx.Display.GetCount() > 1: for i in range(wx.Display.GetCount()): display = wx.Display(i) if display.IsPrimary(): _, _, width, height = display.GetGeometry() else: width, height = wx.GetDisplaySize() return(width, height) GlobalXmlFile = str('myface_account_0.01.xml') GlobalXmlRoot, GlobalXmlTree = getXmlTree(GlobalXmlFile) class TextEntryDisplay(wx.Frame): def __init__(self, *args, **kw): super(TextEntryDisplay, self).__init__(None) MainPanel = wx.Panel(self) MainSizer = wx.BoxSizer(wx.VERTICAL) TextInputPanel = wx.Panel(MainPanel) TextInputSizer = wx.BoxSizer(wx.VERTICAL) TextLabelWidj = wx.StaticText(TextInputPanel, -1, "Posting As $Username") TextInputWidj = wx.TextCtrl(TextInputPanel, -1, style = wx.TE_MULTILINE) TextInputSizer.Add(TextLabelWidj, 0) TextInputSizer.Add(TextInputWidj, 1, wx.EXPAND) TextInputPanel.SetSizer(TextInputSizer) TextInputPanel.Layout() OptInputPanel = wx.Panel(MainPanel) OptInputSizer = wx.BoxSizer(wx.HORIZONTAL) TitleLabelWidj = wx.StaticText(OptInputPanel, -1, "Topic:") TitleInputWidj = wx.TextCtrl(OptInputPanel, -1) OptInputSizer.Add(TitleLabelWidj, 0) OptInputSizer.Add(TitleInputWidj, 0) OptInputPanel.SetSizer(OptInputSizer) OptInputPanel.Layout() MainSizer.Add(TextInputPanel, 1, wx.EXPAND) MainSizer.Add(OptInputPanel, 0) MainPanel.SetSizer(MainSizer) MainPanel.Layout() #self.CenterOnScreen() self.makeMenuBar() self.CreateStatusBar() def makeMenuBar(self): fileMenu = wx.Menu() FileAttach = fileMenu.Append(-1, "Attach Photo", "Browse") FilePost = fileMenu.Append(-1, "Post", "Post to Front Page") FileSave = fileMenu.Append(-1, "Save", "Save to file...") FileLoad = fileMenu.Append(-1, "Open", "Open file here") fileMenu.AppendSeparator() FileExit = fileMenu.Append(wx.ID_EXIT) menuBar = wx.MenuBar() menuBar.Append(fileMenu, "&File") self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.OnFileAttach, FileAttach) self.Bind(wx.EVT_MENU, self.OnFilePost, FilePost) self.Bind(wx.EVT_MENU, self.OnFileSave, FileSave) self.Bind(wx.EVT_MENU, self.OnFileLoad, FileLoad) self.Bind(wx.EVT_MENU, self.OnFileExit, FileExit) def OnFileAttach(self, event): #Things And Stuff """ """ def OnFilePost(self, event): """ Things """ Content = self.TextInputWidj.GetValue() Title = self.TitleInputWidj.GetValue() Author = str("namos heerski") index = len(GlobalXmlRoot.find('threads').findall('thread')) GlobalXmlRoot.find('threads').append(ET.SubElement(GlobalXmlRoot.find('threads'), 'thread')) GlobalXmlRoot.find('threads')[index].append(ET.SubElement(GlobalXmlRoot.find('threads')[index], 'title')) GlobalXmlRoot.find('threads')[index].append(ET.SubElement(GlobalXmlRoot.find('threads')[index], 'author')) GlobalXmlRoot.find('threads')[index].append(ET.SubElement(GlobalXmlRoot.find('threads')[index], 'content')) GlobalXmlRoot.find('threads')[index].find('title').text = Title GlobalXmlRoot.find('threads')[index].find('author').text = Author GlobalXmlRoot.find('threads')[index].find('content').text = Content #GlobalXmlTree.write(GlobalXmlFile) self.Close(True) def OnFileSave(self, event): """ #yup eh """ def OnFileLoad(self, event): """ #More Things """ def OnFileExit(self, event): #Hold on I got this one, it's right down.... self.Close(True) class ProfileDisplay(wx.Frame): def __init__(self, *args, **kw): super(ProfileDisplay, self).__init__(*args, **kw) self.MainPanel = wx.Panel(self) self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) self.makeMenuBar() self.PrepProfile() self.PrepThreads() self.CreateStatusBar() self.MainSizer.Add(self.ProfilePanel, 0, wx.ALIGN_LEFT) self.MainSizer.Add(self.ThreadsPanel, 0, wx.ALIGN_RIGHT) self.MainPanel.SetSizer(self.MainSizer) self.MainPanel.Layout() def makeMenuBar(self): fileMenu = wx.Menu() FileOpen = fileMenu.Append(-1, "Open Profile", "Browse") FileSave = fileMenu.Append(-1, "SaveProfile", "Browse") FilePost = fileMenu.Append(-1, "Post To Blog", "Browse") FilePrefs = fileMenu.Append(-1, "Preferences", "Browse") fileMenu.AppendSeparator() FileExit = fileMenu.Append(wx.ID_EXIT) menuBar = wx.MenuBar() menuBar.Append(fileMenu, "&File") self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.OnFileOpen, FileOpen) self.Bind(wx.EVT_MENU, self.OnFileSave, FileSave) self.Bind(wx.EVT_MENU, self.OnFilePost, FilePost) self.Bind(wx.EVT_MENU, self.OnFilePrefs, FilePrefs) self.Bind(wx.EVT_MENU, self.OnFileExit, FileExit) def OnFileOpen(self, event): """ Loads an xml file from disk """ path = fileBrowse(self) GlobalXmlRoot = getXmlTree(path) def OnFileSave(self, event): """ Writes all Profile Information to xml on disk """ def OnFilePost(self, event): """ Opens a text input window Text input window should update directly to xml perhaps based on flags calling it. Should Generic the text input for blogs and comments. """ TextInput = TextEntryDisplay(None, title = 'Hello') TextInput.Show() def OnFilePrefs(self, event): """ Opens configuration window to change specific values like access permissions, personal info, status?, possibly some layout management? like sliders for percentage of screen space? Future rewrites I think... """ def OnFileExit(self, event): self.Close(True) def PrepProfile(self): self.ProfilePanel = wx.Panel(self.MainPanel) ProfileSizer = wx.BoxSizer(wx.VERTICAL) Username = GlobalXmlRoot.find('profileinfo').find('name').text ProfilePicDir = GlobalXmlRoot.find('profileinfo').find('pfp').text #Location = xmlroot.find('profileinfo').find('location').text Status = GlobalXmlRoot.find('profileinfo').find('status').text ProfilePic = wx.Image(ProfilePicDir) ProfilePicCtrl = wx.StaticBitmap(self.ProfilePanel, wx.ID_ANY, wx.Bitmap(ProfilePic)) UsernameCtrl = wx.StaticText(self.ProfilePanel, -1, Username) StatusCtrl = wx.StaticText(self.ProfilePanel, -1, Status) ProfileSizer.Add(ProfilePicCtrl, 0, wx.ALIGN_LEFT) ProfileSizer.Add(UsernameCtrl, 0, wx.ALIGN_LEFT) ProfileSizer.Add(StatusCtrl, 0, wx.ALIGN_LEFT) self.ProfilePanel.SetSizer(ProfileSizer) self.ProfilePanel.Layout() def PrepThreads(self): self.ThreadsPanel = wx.Panel(self.MainPanel) ThreadsSizer = wx.BoxSizer(wx.VERTICAL) """ Need to find out how many threads there are """ ThreadCount = len(GlobalXmlRoot.find('threads').findall('thread')) #self.SetStatusText(str(ThreadCount)) for i in range(ThreadCount): ThreadPanel = wx.Panel(self.ThreadsPanel) ThreadSizer = wx.BoxSizer(wx.VERTICAL) Content = GlobalXmlRoot.find('threads')[i].find('content').text Author = GlobalXmlRoot.find('threads')[i].find('author').text Title = GlobalXmlRoot.find('threads')[i].find('title').text ContentCtrl = wx.StaticText(ThreadPanel, -1, Content) AuthorCtrl = wx.StaticText(ThreadPanel, -1, Author) TitleCtrl = wx.StaticText(ThreadPanel, -1, Title) ThreadSizer.Add(ContentCtrl, 0, wx.ALIGN_CENTER_VERTICAL) ThreadSizer.Add(AuthorCtrl, 0, wx.ALIGN_CENTER_VERTICAL) ThreadSizer.Add(TitleCtrl, 0, wx.ALIGN_CENTER_VERTICAL) font = ContentCtrl.GetFont() font.PointSize += 10 font = font.Bold() ThreadPanel.SetSizer(ThreadSizer) ThreadPanel.Layout() ThreadsSizer.Add(ThreadPanel, 0) self.ThreadsPanel.SetSizer(ThreadsSizer) self.ThreadsPanel.Layout() if __name__ == '__main__': app = wx.App() start_frame = ProfileDisplay(None, title = 'MyFace') start_frame.Show() app.MainLoop()


>>
Basement Dwelling Neckbeard 26/01/31(Sat)05:17 No. 5823

Stick with one until you have a minimally viable working product!


>>
Basement Dwelling Neckbeard 26/01/31(Sat)05:23 No. 5824

Isnt this what Tox is?


>>
Basement Dwelling Neckbeard 26/01/31(Sat)16:12 No. 5826

>>5824
That wiki page was a wild ride.
And yes, it looks like that group of college educated computer programmers built approximatly what I wanted to. I find it really cool to know that I had the right idea, but just lacked the skillz and resources to actually do it. I do have more skills and resources now... maybe it's time to circle back to this.

>>5823
lol what product? Can't put advertising on a decentralized network lel



[Return] [Entire Thread] [Last 50 posts]



Delete post []
Password  
Report post
Reason