$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ソケットについて
Search
jambo-develop-team
March 11, 2024
0
36
ソケットについて
TCP/IP等ネットワークプロトコルを使って データを双方向で送受信するための手段
TCP/IPという技術を使いやすくした API、ライブラリのようなもの
jambo-develop-team
March 11, 2024
Tweet
Share
More Decks by jambo-develop-team
See All by jambo-develop-team
FigmaMCP+Cursorで直感的にUIを作成してみる🎨
jambo_develop_team
0
110
株式会社ジャンボ_紹介資料
jambo_develop_team
0
4.6k
StoreKit2を使用した課金実装
jambo_develop_team
0
360
AppDelegateで何をすべきか
jambo_develop_team
0
540
SwiftUIのpropertyWrapperをふんわり理解する
jambo_develop_team
0
480
JetpackCompose触ってみた
jambo_develop_team
0
29
KMPを触ってみた
jambo_develop_team
0
20
モバイルアプリの通知機能を AmazonSNSで実装する
jambo_develop_team
0
38
アジャイル入門
jambo_develop_team
0
15
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
253
22k
Being A Developer After 40
akosma
91
590k
Thoughts on Productivity
jonyablonski
73
4.9k
Typedesign – Prime Four
hannesfritz
42
2.9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.6k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
Practical Orchestrator
shlominoach
190
11k
Bash Introduction
62gerente
615
210k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Transcript
ીࠜݪޫҰ ιέοτʹ͍ͭͯ
None
ൃදͷత ιέοτ͕Կऀͳͷ͔ Կͱͳ͘ͰΠϝʔδͰ͖ΔΑ͏ʹ͢Δ
݁ہιέοτͬͯԿʁ
5$1*1 ʢݸਓతͳݟղʣ
5$1*1ωοτϫʔΫϓϩτίϧΛͬͯ σʔλΛํͰૹड৴͢ΔͨΊͷखஈ 5$1*1ͱ͍͏ٕज़Λ͍ͨ͘͢͠ "1*ɺϥΠϒϥϦͷΑ͏ͳͷ ͏গ͠۩ମతʹ
ͦͦ5$1*1ͬͯʁ
5$1*1ͱ ௨৴نɾ௨৴ʹ͓͚Δଋࣄ ΞϓϦέʔγϣϯ )551ɺ4.51ɺ%/4 τϥϯεϙʔτ 5$1ɺ6%1 Πϯλʔωοτ
*1ɺ"31ɺ3"31 ωοτϫʔΫΠϯλʔϑΣʔε &UIFSOFUɺ111
Πϯλʔωοτͷׂɺ*1ΞυϨεΛݩʹσʔλ ͷΓऔΓΛ͢Δ૬खΛࢦఆ͢Δ Πϯλʔωοτ
τϥϯεϙʔτͷׂɺσʔλΛదͳΞϓϦέ ʔγϣϯʹৼΓ͚Δ͜ͱ τϥϯεϙʔτ σʔλ σʔλ σʔλ ΞϓϦ" ΞϓϦ#
τϥϯεϙʔτͷׂɺσʔλΛదͳΞϓϦέ ʔγϣϯʹৼΓ͚Δ͜ͱ τϥϯεϙʔτ σʔλ σʔλ σʔλ ΞϓϦ" ΞϓϦ# ϙʔτ൪߸ΛݩʹৼΓ͚
τϥϯεϙʔτͷ௨৴ϓϩτίϧछྨ 5$1ͱ6%1
5$1 5SBOTNJTTJPO$POUSPM1SPUPDPM ૹ͍͍ͬͯʁ ͍͍Αʂ ૹΔͶʂ ίωΫγϣϯܕɹ৴པੑॏࢹ ϝʔϧϑΝΠϧͳͲ࣭ΛٻΊΔ௨৴ʹ༻͢Δ ͪΐͬͱࠞΈ ߹ͬͯΔ ແࣄड͚औͬͨΑʂ
όΠτૹ ΔͶʂ ࠶ૹ͢ΔͶʂ
5$1 5SBOTNJTTJPO$POUSPM1SPUPDPM ૹ͍͍ͬͯʁ ͍͍Αʂ ૹΔͶʂ ίωΫγϣϯܕɹ৴པੑॏࢹ ϝʔϧϑΝΠϧͳͲ࣭ΛٻΊΔ௨৴ʹ༻͢Δ ͪΐͬͱࠞΈ ߹ͬͯΔ ແࣄड͚औͬͨΑʂ
όΠτૹ ΔͶʂ ࠶ૹ͢ΔͶʂ ΣΠϋϯυγΣΠΫ
6%1 6TFS%BUBHSBN1SPUPDPM ͲΜͲΜૹΔΑʂ ίωΫγϣϯϨεܕɹεϐʔυॏࢹ *1ిετϦʔϛϯάαʔϏεͳͲରଟϦΞϧλΠϜੑΛٻΊΔ௨৴ ड͚औΓʹࣦഊ͠ ͓ͯߏ͍ͳ͠ ؾʹͤͣૹΔΑʂ
ৄͪ͘͜͠Β εϥεϥΘ͔ΔωοτϫʔΫ 5$1*1ͷ͖΄Μ
5$1*1͔͚ͬͨͲιέοτʁ
5$1ʹ͓͚Διέοτ௨৴ͷྲྀΕʹ͍ͭͯ ιέοτ௨৴͢ΔػثɺͦΕͧΕͰιέοτͷ࣮͕ඞཁ ίωΫγϣϯͷ४උ ίωΫγϣϯͷཱ֬ σʔλަ ίωΫγϣϯͷղ์
αʔόʔ ΫϥΠΞϯτ 4PDLFU 4PDLFU MJTUFO DPOOFDU SFDFJWF TFOE SFDFJWF TFOE
DMPTF DMPTF ίωΫγϣϯ४උ ίωΫγϣϯཱ֬ σʔλަ ίωΫγϣϯղ๏
ιέοτΫϥΠΞϯτଆ final class SocketClient { init(_ loginUser: LoginUserEntity) { self.loginUser
= loginUser let host = NWEndpoint.Host(CustomUrl.targetIp) let port = NWEndpoint.Port(integerLiteral: CustomUrl.Port) let using: NWParameters = .tcp connection = NWConnection(host: host, port: port, using: using) connection.stateUpdateHandler = {[weak self] newState in guard let strongSelf = self else { return } strongSelf.connectionState = newState switch newState { case .setup: print("HOGE: ηοτΞοϓ”) case .waiting: print("HOGE: ػ") case .preparing: print("HOGE: ४උ") case .ready: print("HOGE: ४උྃ”) private static let productionIp = “xxx.com” static let port: UInt16 = 8_888 J04ΞϓϦ ιέοτॳظԽॲཧ ίωΫγϣϯͷ४උ ίωΫγϣϯཱ֬
ιέοτΫϥΠΞϯτଆ final class SocketClient { init(_ loginUser: LoginUserEntity) { self.loginUser
= loginUser let host = NWEndpoint.Host(CustomUrl.targetIp) let port = NWEndpoint.Port(integerLiteral: ɹɹɹɹɹɹɹɹɹɹɹCustomUrl.port) let using: NWParameters = .tcp connection = NWConnection(host: host, port: port, using: using) connection.stateUpdateHandler = {[weak self] newState in guard let strongSelf = self else { return } strongSelf.connectionState = newState switch newState { case .setup: print("HOGE: ηοτΞοϓ”) case .waiting: print("HOGE: ػ") case .preparing: print("HOGE: ४උ") case .ready: print("HOGE: ४උྃ”) private static let productionIp = “xxx.com” static let port: UInt16 = 8_888 Πϯλʔωοτ τϥϯεϙʔτ τϥϯεϙʔτ ʁʁʁ
ιέοτΫϥΠΞϯτଆ final class SocketClient { init(_ loginUser: LoginUserEntity) { self.loginUser
= loginUser let host = NWEndpoint.Host(CustomUrl.targetIp) let port = NWEndpoint.Port(integerLiteral: ɹɹɹɹɹɹɹɹɹɹɹCustomUrl.port) let using: NWParameters = .tcp connection = NWConnection(host: host, port: port, using: using) connection.stateUpdateHandler = {[weak self] newState in guard let strongSelf = self else { return } strongSelf.connectionState = newState switch newState { case .setup: print("HOGE: ηοτΞοϓ”) case .waiting: print("HOGE: ػ") case .preparing: print("HOGE: ४උ") case .ready: print("HOGE: ४උྃ”) private static let productionIp = “xxx.com” static let port: UInt16 = 8_888 Πϯλʔωοτ τϥϯεϙʔτ τϥϯεϙʔτ ΣΠϋϯυγΣΠΫ
ιέοτΫϥΠΞϯτଆ func send(to receiver: SocketMsgProtocol, text: String, messageType: ChatMessageType, handler:
@escaping (SocketMessage?) -> Void) { ~~~~ } func receive(on connection: NWConnection) { connection.receive(minimumIncompleteLength: 0, maximumLength: Int(UInt32.max)) {[weak self] (data, _, _, error) in guard let text = data?.toStringWithEncodeByUTF8() ~~~ } σʔλަ
ιέοτΫϥΠΞϯτଆ func releaseSocketClient() { socketClient = nil } ɹɹdeinit {
connection.cancel() } ίωΫγϣϯͷղ์
·ͱΊ w 5$1*1ͷٕज़Λͬͯ؆୯ʹσʔλͷΓऔΓΛߦ͑ΔΑ͏ ʹͨ͠ͷ͕ιέοτ w 5$1ͱ6%1ͱ͍͏̎ͭͷ௨৴ϓϩτίϧ͕͋Δ w ࣄͷຊ࣭Λָ͍ͬͯ͘͠͞
͓ΘΓ